Skip to content

Instantly share code, notes, and snippets.

@gnarf
Created July 2, 2012 07:42
Show Gist options
  • Save gnarf/3031719 to your computer and use it in GitHub Desktop.
Save gnarf/3031719 to your computer and use it in GitHub Desktop.
Just a slideshow I hacked out for someone a year or two ago
/*! simple slideshow example
* gnarf
* This work is licensed under a Creative Commons Attribution 3.0 Unported License
* http://creativecommons.org/licenses/by/3.0/
*/
(function($) {
$(function() {
var timeout,
ss = $(".slideshow"),
images = ss.find("li"),
current = 0,
length = images.length;
delay = 3500;
if ( length ) {
queue();
}
ss.hover(function() {
clearTimeout( timeout );
}, queue);
function advance() {
$(this).removeClass('shown');
current = ( current + 1 ) % length;
ss.prepend( images.eq( current ).addClass('shown') );
}
function queue() {
timeout = setTimeout( advance, delay );
}
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment