Re: The need to re-subscribe to requestAnimationFrame

On Sat, Mar 2, 2013 at 5:03 AM, David Bruant <bruant.d@gmail.com> wrote:

> If someone wants to reuse the same function for requestionAnimationFrame,
> he/she has to go through:
>     requestAnimationFrame(function f(){
>         requestAnimationFrame(f);
>         // do stuff
>     })
>

FYI, this pattern is cleaner, so you only have to call
requestAnimationFrame in one place:

function draw() {
    // render
    requestAnimationFrame(draw);
}
draw();

-- 
Glenn Maynard

Received on Saturday, 2 March 2013 14:15:30 UTC