Re: requestAnimationFrame

On Mon, Nov 15, 2010 at 4:07 PM, Robert O'Callahan <robert@ocallahan.org>wrote:

> On Tue, Nov 16, 2010 at 12:55 PM, Gregg Tavares (wrk) <gman@google.com>wrote:
>
>> I've seen proposals for something more like
>>
>>       element.setInternvalIfVisible(func, internval);
>>
>> Which is the same as setInterval but only gets called if the element is
>> visible.  With that kind of API there is no connection to rendering. Each
>> area that needs animation can set the framerate it is hoping to get. The UA
>> can throttle if it wants to.
>>
>
> What happens if one element's event handler makes another element visible,
> will the second element's timer be able to fire or not?
>

Does it matter? What happens now? Now, with setInterval there is no
connection to rendering. I set the code to update one element to have an
interval of 16 and another to have an interval of 100. If the first one
makes the second one visible that doesn't effect whether or not the second
one's set interval function gets called. If there was a setIntervalIfVisible
and that behavior was browser independent how would that make things worse
than they are today? It seem like "if visible" is just a hint to the browser
that it doesn't need to call the interval function if it doesn't want to. It
doesn't need to be a guaranteed that it will be called when visible any more
than the current setInterval is a guarantee that it will be called at the
interval rate.


>
> When an element becomes visible, does its timer fire immediately if the
> last firing was more than 'interval' ago?
>

Yes? No? Does it matter? What happens now?

I'm not trying to be argumentative. I'm just not seeing the issue. Certainly
I'd like various areas to be updated together, or in sync, or when visible
but that seems like it could be up the UA. If one UA has a simple
implementation and another UA as more complex one that gives a better user
experience then that's reason to switch to that browser.


>
> If the author just wants a smooth animation, what should they pass as the
> interval? For smooth animations, it seems to me that the browser alone
> should choose the frame rate.
>

This seems like you'd just pass in 0 for the interval. The UA can decide
whether or not to call you as fast as it can or at 60hz or whatever it
things is appropriate just as it does for setInterval today.



> Rob
> --
> "Now the Bereans were of more noble character than the Thessalonians, for
> they received the message with great eagerness and examined the Scriptures
> every day to see if what Paul said was true." [Acts 17:11]
>

Received on Tuesday, 16 November 2010 00:46:03 UTC