requestAnimationFrame, setInterval and setTimeout

Asked

Viewed 140 times

4

I would like to understand more about the nature of these three functions cited above. What is the main objective for each one? In the case of animations, which is the best option for changes in the DOM ?

1 answer

1


For what I’ve used

requestAnimationFrame It is more for games or animations, it is like a set interval only that without problems with the difference of MS from one computer to another, came along with CSS3 and HTML5 https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame

Setinterval is the method to perform an X-millisecond action http://www.w3schools.com/jsref/met_win_setinterval.asp

Settimeout is the method that runs a method ONLY ONCE after X milliseconds http://www.w3schools.com/jsref/met_win_settimeout.asp

Depending on the animation it is good you use css3

http://www.w3schools.com/css/css3_animations.asp

Browser other questions tagged

You are not signed in. Login or sign up in order to post.