-
Notifications
You must be signed in to change notification settings - Fork 2
/
stacked-gallery.js
34 lines (26 loc) · 1007 Bytes
/
stacked-gallery.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
(function($) {
$.fn.reverse = [].reverse;
$.fn.shift = [].shift;
$.fn.push = [].push;
$.fn.stackedGallery = function(params) {
var elements = $(this).children().reverse();
var params = $.extend( { display_duration: 4000, fadeout_duration: 800, fadein_duration: 200, n_elem: elements.length }, params);
var animate = function() {
var current = elements[0];
$(current).fadeOut(params.fadeout_duration, function() {
elements.shift();
elements.push(current);
$.each(elements, function(index, elem) {
$(elem).css('z-index', (params.n_elem-index));
});
$(current).fadeIn(params.fadein_duration);
setTimeout(function() { animate() }, params.display_duration);
});
}
$.each(elements, function(index, elem) {
$(elem).css('position', 'absolute');
});
setTimeout(function() { animate() }, params.display_duration);
return $(this);
};
})(jQuery);