Created
November 11, 2011 21:05
-
-
Save thanos/1359266 to your computer and use it in GitHub Desktop.
javascript - runs the function, worker, through a number of steps with a delay between each step. Can be used to cycle through images.
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
| /* | |
| * runs the function, worker, through a number of steps with a delay between each step. | |
| * This example flicks through a bunch of images. | |
| * step(0,10, function(num, stop) { | |
| * $('#mo').attr('src', 'images/'+num+'.jpg'); | |
| * }, 600); | |
| */ | |
| function step(ind, stop, worker, delay) { | |
| if (ind < stop) { | |
| setTimeout(function(){ | |
| worker(ind, stop); | |
| step(ind + 1, stop, worker, delay); | |
| }, delay); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment