Proper usage of requestAnimationFrame