Created
February 13, 2012 23:13
-
-
Save javiertoledo/1821351 to your computer and use it in GitHub Desktop.
A simple multi-instance slideshow with jQuery
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
.photos | |
- @photos.each do |photo| | |
.photo=image_tag photo.url(:medium) |
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
updateSlideshows = -> | |
for slideshow in $('.photos') | |
if (active = $('.active',slideshow)).length == 0 | |
if activable = $('.photo',slideshow)[0] | |
$(activable).addClass('active') | |
$(activable).fadeIn(500) | |
else if (activable = (active.next('.photo')[0] || $('.photo',slideshow)[0])) | |
$(activable).addClass('active') | |
$(activable).fadeIn(1000) | |
$(active).removeClass('active') | |
$(active).fadeOut(1000) | |
$ -> | |
window.setInterval(updateSlideshows,6000) | |
updateSlideshows() |
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
.photos | |
width: 640px //The images width here | |
height: 480px //The images height here | |
position: relative | |
.photo | |
display: none //Initially hiddes all slides | |
position: absolute | |
top: 0 | |
left: 0 | |
.active | |
z-index: 1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment