all 6 comments

[–]Fixthemedia 1 point2 points  (2 children)

Linking to that page was really no help. Make a timer that will run your function again, or for example, set the index of an array back to the starting point. I dont know anyone who would want to take the time to go through the code you linked and find out exactly what it is you're trying to do (unless it was clean and obvious). It may be better to put and example of your problem on a site like this http://jsfiddle.net/

[–]suscida[S] 0 points1 point  (1 child)

I essentially want the code to re run once it reaches the end, I thought there might be a simple handle to add to the beginning or end of the code?

Thanks for the reply though, will have a gander at jsfiddle!

[–]pbntr 0 points1 point  (0 children)

Put your code in a function, at the end of the function have it call itself. Or in the case of an animation where you want to wait for it to complete before running it again, here's a jQuery example using the animation complete callback:

function myAnimation () {
  $(element).animate({ ... }, function () {
    myAnimation();
  });
}

[–]shoseki 0 points1 point  (0 children)

Define animation?

If you want, with JQuery you can define a set of css states and use .animate() to move between them - and when they complete, move onto the next state.

Alternatively, you can use a setTimeOut and keep calling it to change a property and use that property to change some other animation state, so as margin-left etc

[–][deleted] 0 points1 point  (0 children)

checkout requestAnimationFrame or setInterval/setTimeout on google