Making a javascript application, at somepoint, involves use of setTimeout
and setInterval
functions. Well, the possibility increases even more, when one needs to animate elements. So we know what it means to use these two functions.
Fortunately we have a new method, called requestAnimationFrame()
, which is elegant and effective. Now animations will not eat up mobile battery life, but still be smooth. This is optimised to takecare of the host environment, such as mobile browser, desktop browser etc. It even minimises the repeat call, if the application using it, is not visible or scrolled out of view, sweet.
Check, which browsers and versions support this function, just to make yourself clear.
Here are few links which explain requestAnimationFrame
function in more detail.
Its kind of saying bye bye
to setTimeout
and setInterval
.
Happy Animating.