Re: requestAnimationFrame

* Ojan Vafai wrote:
>On Fri, Nov 19, 2010 at 2:54 PM, Cameron McCormack <> wrote:
>> Darin Fisher:
>> I can imagine a situation where you have an animation that goes for,
>> say, 10 seconds, and once the animation finishes something else happens.
>> The 1 second maximum period seems useful in this case, because you might
>> make the tab visible again for a long time, but you expect the
>> “something else” to happen.  It’s pretty natural to do the checking for
>> whether the animation has gone past its end time within the callback.
>What's an acutal example where you might want this that couldn't just wait
>until the tab was visible again? This use-case doesn't seem very common. As
>you say, it's also probably not well met due to throttling.

Well, if every event handler has "If time is past my end time, clean up
and unregister the handler" logic, and you do not care about possible
wait times when resuming the tab (for instance, the cleanup may load
additional resources from the network which one might expect to load
in the background), and find shared state manipulation far fetched
(say, on disposal the handler may change cookies or local storage to
indicate, say, you've already watched a full-screen ad on the page),
then the only thing that could leak out of tabs, as far as my browser
is concerned, is audio.

To make up a simple case, you might have a visual progess indicator
where the end time is determined by some network activity: when it
finishes you get an audible "done" indicator and you bind the "done" 
logic to the animation handler, not the network handler. Obviously
that does not address your question, since "couldn't" never applies
here, you could always just use setTimeout and setInterval and burn
cycles, or whatever else gurantees your script runs even when the tab
is in the background, and implement the logic as you see fit.
Björn Höhrmann · ·
Am Badedeich 7 · Telefon: +49(0)160/4415681 ·
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · 

Received on Saturday, 20 November 2010 01:35:31 UTC