Animation Loops in JavaScript using requestAnimationFrame