Created
September 22, 2011 20:37
-
-
Save pelagisk/1235967 to your computer and use it in GitHub Desktop.
Funkar ej?
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
| window.addEvent('domready',function() { | |
| /* settings */ | |
| var showDuration = 1000; | |
| var container = $('slideshow-container'); | |
| var divs = container.getElements('div'); | |
| var currentIndex = 0; | |
| var interval; | |
| /* opacity and fade */ | |
| divs.each(function(div,i){ | |
| if(i > 0) { | |
| div.set('opacity',0); | |
| } | |
| }); | |
| /* worker */ | |
| var show = function() { | |
| divs[currentIndex].fade('out'); | |
| divs[currentIndex = currentIndex < divs.length - 1 ? currentIndex+1 : 0].fade('in'); | |
| }; | |
| /* start once the page is finished loading */ | |
| window.addEvent('load',function(){ | |
| interval = show.periodical(showDuration); | |
| }); | |
| }); | |
| /* HTML | |
| <div id="slideshow-container"> | |
| <div id="slide">Hej</div> | |
| <div id="slide">Hello</div> | |
| <div id="slide">Tja</div> | |
| <div id="slide">Ho</div> | |
| </div> | |
| */ | |
| /* | |
| #slideshow-container { width:512px; height:384px; position:relative; } | |
| #slideshow-container div { display:block; position:absolute; top:0; left:0; z-index:1; } | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment