3 ms·
Bad practice, requestAnimationFrame is preferred for such purposes: https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame https://devel
by o1y32 3y ago
Bad practice, requestAnimationFrame is preferred for such purposes:
https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame https://developer.mozilla.org/en-US/docs/Web/API/window/requ...
https://stackoverflow.com/questions/38709923/why-is-requestanimationframe-better-than-setinterval-or-settimeout https://stackoverflow.com/questions/38709923/why-is-requesta...
...and based on that I'm afraid you shouldn't be giving out advice on doing animations
- pyentropy 3y agoHe's not using the timer to do per-frame calculations - the GPU does the interpolation using the `transition` property. He's just using the timer for setting the target state.
- IggleSniggle 3y agoThere’s a difference between creating your own draw-loop with setTimeout and requesting a CSS animation. Whether you use requestAnimationFrame which calls your code at every draw step or whether you set a CSS animation directive, you are delegating the animation work to the browser. In either case, the resultant behavior is dependent on browser-code, not your own js. This is very different than setting up your own manual draw loop with setTimeout.