Created
August 24, 2017 15:31
-
-
Save bendc/69489daf094174d85a7240515d9f8480 to your computer and use it in GitHub Desktop.
rAF tutorial: performance time tracking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const time = { | |
start: performance.now(), | |
total: 2000 | |
}; | |
const tick = now => { | |
time.elapsed = now - time.start; | |
if (time.elapsed < time.total) requestAnimationFrame(tick); | |
}; | |
requestAnimationFrame(tick); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment