forked from alimd/CueSlider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cueslider.js
executable file
·60 lines (53 loc) · 1.22 KB
/
cueslider.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
// Zepto/jQuery fadeLoop plugin for fade slide show effects
(function($){
$.extend($.fn,{
cueslider : function(options){
options = $.extend({
duration : 500,
autoPlay : false,
nextBtn : 'div.banner .next',
backBtn : 'div.banner .back',
autoPlayInterval : 3000,
transitionProperty : 'left top opacity'.split(' ')
}, options);
var iszep = !!window.Zepto,
slides = this,
cuePos = [];
slides.cuePos = cuePos;
slides.each(function(){ // store slide positions.
var p,obj = {};
for(var i in options.transitionProperty){
p=options.transitionProperty[i];
obj[p]=$(this).css(p);
}
cuePos.push(obj);
});
cuePos.shifc = function(revert){
if(revert){
this.unshift(this.pop());
}else{
this.push(this.shift());
}
};
slides.refresh = function(){
slides.each(function(i){
$(this).animate(cuePos[i],options.duration);
});
};
$(options.nextBtn).click(function(){
slides.cuenext();
});
$(options.backBtn).click(function(){
slides.cueback();
});
},
cuenext : function(){
this.cuePos.shifc();
this.refresh();
},
cueback : function(){
this.cuePos.shifc(true);
this.refresh();
}
});
})($);