use requestAnimationFrame instead of setInterval for animation.