Created
August 28, 2017 13:19
-
-
Save bendc/91ed22ba806c29e569944b83dfa03ad5 to your computer and use it in GitHub Desktop.
rAF tutorial: better setTimeout
This file contains 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 delay = (callback, duration) => { | |
const tick = () => | |
getProgress(time) < 1 ? requestAnimationFrame(tick) : callback(); | |
const time = { | |
duration, | |
id: requestAnimationFrame(tick) | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment