Skip to content

Instantly share code, notes, and snippets.

@dotherightthing
Created December 17, 2019 22:33
Show Gist options
  • Save dotherightthing/9bd6deab097ee0d177222469aa800339 to your computer and use it in GitHub Desktop.
Save dotherightthing/9bd6deab097ee0d177222469aa800339 to your computer and use it in GitHub Desktop.
window.requestAnimationFrame #js #css

window.requestAnimationFrame

Animating with requestAnimationFrame Since the interval parameter is irrelevant in complex animations, as there’s no guarantee that it will be honored, a new API has been designed: requestAnimationFrame. It’s simply a way to tell the browser “before drawing the next frame on the screen, execute this game logic/animation processing”. The browser is in charge of choosing the best moment to execute the code, which results in a more efficient use of resources[3].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment