Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fernandofleury/1792fadc28ff914ae4c5b47f0ff5f9ae to your computer and use it in GitHub Desktop.
Save fernandofleury/1792fadc28ff914ae4c5b47f0ff5f9ae to your computer and use it in GitHub Desktop.
animationFrame.js
const animationFrame = timestamp => {
if (!this.startTime) {
this.startTime = timestamp;
}
this.delta = timestamp - this.startTime;
if (this.delta >= updateDiff) {
this.update(this.delta);
this.startTime = 0;
}
window.requestAnimationFrame(this.animationFrame);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment