Created
July 2, 2012 07:42
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! 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