Last active
May 5, 2018 16:03
-
-
Save v0lkan/796206f7e420fec4b973fd6c7ccab4f3 to your computer and use it in GitHub Desktop.
Double requestAnimatioFrame FTW!
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 rafraf = (callback) => { | |
if (!window.requestAnimationFrame) {return null;} | |
return window.requestAnimationFrame(() => | |
window.requestAnimationFrame(callback) | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I deleted the description in the comments because it was not telling the whole story, and it’s harder to write things than to show it since the root of the problem is related to time, timing, loops, queues, events and things like that; which can better be explained visually than in written form.
Besides there are few variationns on the theme that shows when you might (and when you might not) need a double
requestAnimationFrame
which, again, can be better expressed in an audio-visual form showing all the dev tool and profiler outputs.I’m recording a screencast about it: I will link to the video when it’s done.
Until then… May the source be with you.