-
Notifications
You must be signed in to change notification settings - Fork 1
/
jquery.cycle2.cover.js
95 lines (86 loc) · 2.9 KB
/
jquery.cycle2.cover.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
(function($){
"use strict";
$.fn.cycle.transitions.cover = {
transition: function( opts, currEl, nextEl, fwd, callback ) {
var uncover = false;
if ((fwd && opts.coverEnterAnimation == 'uncover')
|| (!fwd && opts.coverExitAnimation == 'uncover')) {
uncover = true;
}
$( nextEl ).css({
display: 'block',
visibility: 'visible'
});
opts.container.css('overflow', 'hidden');
var width = opts.container.width();
var height = opts.container.height();
var speed = opts.speed;
var element = uncover ? currEl : nextEl;
opts = opts.API.getSlideOpts( uncover ? opts.currSlide : opts.nextSlide );
var props1 = { left: -width, top: 0 };
if (fwd) {
if (opts.coverEnterPosition == 'top') {
props1 = { left: 0, top: -height };
}
else if (opts.coverEnterPosition == 'right') {
props1 = { left: width, top: 0 };
}
else if (opts.coverEnterPosition == 'bottom') {
props1 = { left: 0, top: height };
}
}
else {
props1 = { left: width, top: 0 };
if (opts.coverExitPosition == 'top') {
props1 = { left: 0, top: -height };
}
else if (opts.coverExitPosition == 'left') {
props1 = { left: -width, top: 0 };
}
else if (opts.coverExitPosition == 'bottom') {
props1 = { left: 0, top: height };
}
}
var props2 = { left: 0, top: 0 };
if (uncover) {
$(element)
.animate(props1, speed, opts.easing, callback)
.queue('fx', $.proxy(reIndex, this))
.animate(props2, 0, opts.easing, callback);
}
else {
$(element)
.css(props1)
.queue('fx', $.proxy(reIndex, this))
.animate(props2, speed, opts.easing, callback);
}
function reIndex(nextFn) {
this.stack(opts, currEl, nextEl, fwd);
nextFn();
}
},
stack: function( opts, currEl, nextEl, fwd ) {
var i, z;
var f = fwd;
if ((fwd && opts.coverEnterAnimation == 'uncover')
|| (!fwd && opts.coverExitAnimation == 'uncover')) {
f = !fwd;
}
if (f) {
z = 1;
for (i = opts.nextSlide - 1; i >= 0; i--) {
$(opts.slides[i]).css('zIndex', z++);
}
for (i = opts.slideCount - 1; i > opts.nextSlide; i--) {
$(opts.slides[i]).css('zIndex', z++);
}
$(nextEl).css('zIndex', opts.maxZ);
$(currEl).css('zIndex', opts.maxZ - 1);
}
else {
opts.API.stackSlides( nextEl, currEl, fwd );
$(currEl).css('zIndex', 1);
}
}
}
})(jQuery);