Updated lib to use requestAnimationFrame for better smoothness