Re: requestAnimationFrame

On Mon, Nov 15, 2010 at 6:17 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 11/15/10 6:55 PM, Gregg Tavares (wrk) wrote:
>>
>> How would setInterval with multiple functions on
>> mozRequestAnimationFrame solve this issue? They are still all going to
>> get called at the fastest interval right?
>
> Why?
>
> setInterval(function() {
>  window.requestAnimationFrame(function redrawElem1() { /* ... */ });
> }, 33);
> setInterval(function() {
>  window.requestAnimationFrame(function redrawElem2() { /* ... */ });
> }, 100);

My suggestion is that

window.requestAnimationFrame(function redrawElem1() { ... }, 33);
window.requestAnimationFrame(function redrawElem1() { ... }, 100);

would be equivalent to the above (or rather, would be equivalent to
using setTimeout).

Though maybe limited-rate animations aren't common enough that the
short-hand is needed.

/ Jonas

Received on Tuesday, 16 November 2010 05:28:32 UTC