Scheduling for Animations
For fast visual updates such as canvas or DOM animations, we can either use the interval operator with a very low millisecond value or we can make a Scheduler that uses a function like setTimeout internally to schedule notifications.
But neither approach is ideal. In both of them we’re throwing all these updates at the browser, which may not be able to process them quickly enough. That happens because the browser is trying to render a frame and then it receives instructions to render the next one, so it drops the current frame to keep up the speed. The results are choppy animations. And we have enough of those on the web.
Browsers have a native way to handle animations, and they provide an API to use it called ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access