Change setInterval() to requestAnimationFrame() if possible

Using setInterval to create animations will cause dropping frames.