Using requestAnimationFrame for more smooth animations.