Skip to content

Instantly share code, notes, and snippets.

@sikanrong
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save sikanrong/9dc87359af16b3c2d2d0 to your computer and use it in GitHub Desktop.

Select an option

Save sikanrong/9dc87359af16b3c2d2d0 to your computer and use it in GitHub Desktop.
javascript animate loop
var animate = function(){
var frameDuration = 1000; //milliseconds
var my = this;
setTimeout(function(){
//do animate stuff here. Use "my" in place of "this" to access the outer object scope within the setTimeout function, if needed.
animate(); //re-calls itself.
}, frameDuration);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment