Skip to content

Instantly share code, notes, and snippets.

@ishmaelahmed
Last active December 19, 2015 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ishmaelahmed/5969819 to your computer and use it in GitHub Desktop.
Save ishmaelahmed/5969819 to your computer and use it in GitHub Desktop.
start you animation with....
//Pseudo code
var id;
animate = function(time){
//Eval time
if(somethingDoneWithTimeIsTrue){
requestAnimationFrame(step)
}
}
pause = function(time){
//some pause function
}
resume = function(time){
//some function to resume animation
}
//Don't do this
animate( performance.now() || Date().getTime() )
pause( performance.now() || Date().getTime() )
resume( performance.now() || Date().getTime() )
//Do this
window.requestAnimationFrame( animate )
window.requestAnimationFrame( pause )
window.requestAnimationFrame( resume )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment