Skip to content

Instantly share code, notes, and snippets.

@jswhisperer
Created June 9, 2013 14:14
Show Gist options
  • Save jswhisperer/5743694 to your computer and use it in GitHub Desktop.
Save jswhisperer/5743694 to your computer and use it in GitHub Desktop.
requestAnimationFrame usage
var globalID;
function repeatOften() {
$("<div />").appendTo("body");
globalID = requestAnimationFrame(repeatOften);
}
$("#start").on("click", function() {
globalID = requestAnimationFrame(repeatOften);
});
$("#stop").on("click", function() {
cancelAnimationFrame(globalID);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment