Is there a way to control the timing of the callback? What can you do with requestAnimationFrame that you can’t do with the web animations API or css animations?
You can control the timing by using a timer inside your
requestAnimationFrame function. It’s not the most ideal solution, but it gets very close.
Advantages over CSS Animations
Advantages over the Web Animations API
The biggest drawback in my opinion is browser support. While there are polyfills out there for it, they aren’t the most performant of things.
requestAnimationFrame has got you covered.
What are you trying to animate? Maybe we can shed some tips on what approach might work better for your needs
Thanks Kirupa. I’m trying to animate all sorts of things!
I find requestAnimationFrame hard to work with compared to WAAPI and CSS (I managed to crash my browser!). Luckily I don’t think I really ever need it to achieve what I want.