- From: Florian Bösch <pyalot@gmail.com>
- Date: Sat, 2 Mar 2013 15:30:27 +0100
- To: Glenn Maynard <glenn@zewt.org>
- Cc: David Bruant <bruant.d@gmail.com>, Webapps WG <public-webapps@w3.org>
Received on Saturday, 2 March 2013 14:30:54 UTC
You can also wrap your own requestAnimationFrameInterval like so: var requestAnimationFrameInterval = function(callback){ var runner = function(){ callback(); requestAnimationFrame(runner); }; runner(); } This will still stop if there's an exception thrown by callback, but it lets you write a cleaner invocation like so: requestAnimationFrameInterval(function(){ // do stuff }); It does not give you a way to stop that interval (except throwing an exception), but you can add your own if you're so inclined. Notably, you could not flexibly emulate requestAnimationFrame (single) via requestAnimationFrameInterval, so if you're gonna pick one semantic to implement, it's the former rather than the latter. On Sat, Mar 2, 2013 at 3:15 PM, Glenn Maynard <glenn@zewt.org> wrote: > 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:30:54 UTC