Skip to content

Instantly share code, notes, and snippets.

@ogorzalka
Created September 6, 2010 16:02
Show Gist options
  • Save ogorzalka/567187 to your computer and use it in GitHub Desktop.
Save ogorzalka/567187 to your computer and use it in GitHub Desktop.
;(function($) {
// Slideshow
$.fn.slideshow = function(options) {
var opts = $.extend({}, {
delay:1000,
interval:5000,
panels:'li'
}, options);
return this.each(function() {
var $this = $(this),
i=0;
$this.find(opts.panels).filter(':not(:first)').css('z-index',2).hide();
setInterval(function() {
i = (!$this.find(opts.panels).eq(i+1).length) ? 0 : i+1;
$this
.find(opts.panels)
.filter(':visible')
.fadeOut(opts.delay)
.css('z-index',2)
.end()
.eq(i)
.show()
.delay(opts.delay)
.css('z-index',1);
}, opts.interval);
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment