Updating requestAnimationFrame function