-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjquery.simpleslide.js
65 lines (51 loc) · 1.33 KB
/
jquery.simpleslide.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
/**
*
* Copyright (c) 2010 Pedro Fuentes ( http://pedrofuent.es )
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
**/
jQuery.fn.simpleSlide = function(a){
a = a || {};
a.duration = a.duration || 5000;
a.transition = a.transition || 1000;
a.stopAt = a.stopAt || false;
a.element = a.element || "img";
var c = $(this);
$(c).css("position","relative");
$(a.element,$(c))
.css({
'position' : 'absolute',
'top' : '0px',
'left' : '0px',
'z-index' : '8'
})
.find(":first")
.addClass("slide-active")
.css('z-index','10');
var cnt = 0;
var interval = setInterval(function(){
if(!isNaN(a.stopAt)){
cnt++;
if(cnt==a.stopAt){
clearTimeout(interval);
}
}
var $active = $(a.element+".slide-active",$(c));
if($active.length == 0) $active = $(a.element+":last",$(c));
var $next = $active.next().length ? $active.next() : $(a.element+":first",$(c));
$active
.addClass("slide-last-active")
.css('z-index','9');
$next
.css({opacity: 0.0})
.addClass("slide-active")
.css('z-index','10')
.animate({opacity: 1.0}, a.transition, function(){
$active
.removeClass('slide-active slide-last-active')
.css('z-index','8');
});
}, a.duration);
}