Using requestAnimationFrame to smooth animation.