Artur Kulig
Jan 24, 2017 · 1 min read

The solution was what I thought it to be.

But it is not weird. Both and do not specify that in a opposite way than it is implemented.

You provide rAF with a callback that is called before a frame is drawn. Before a frame is drawn frame callback list is picked and replaced with an empty one and those picked callbacks are run. Pushing new callbacks to the queue inside a callback will result in functions being added to that new list and called before next frame is drawn.

Maybe not most intuitive, but still accurate.

    Artur Kulig

    Written by

    Human since 1987, web developer since 2008. Seasoned warrior of Frontend tribe. Fought IE6 to extinction.

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade