Animating with javascript: from setInterval to ...
· Animating DOM elements or the content of a canvas is a classical use case for the interval is not as reliable as it seems, and a more suitable API is now available. Animating with setInterval. To animate an element moving 400 pixels on the right with javascript, the basic thing to do is to move it 10 pixels at a time on a regular interval.