joewalnes/smoothie — pull request #26 by imrehg (2012-11-27 13:56:09+00:00)
Title: switch to requestAnimationFrame for rendering - v2

The original method of setTimeout for animation drains on system resources if the tab is not visible, It is somewhat mitigated by some of the modern browsers (Chrome and Firefox tested) which set a maximum 1 setTimeout call per second for background tabs, though this is not a behaviour to be relied upon.

The requestAnimationFrame API aims to fix that with these properties:
- animation is suspended for background tabs, and resumed when forgrounded
- animation frames are aligned with canvas refreshes by the graphics card, thus it should be smoother
- fall back to the old method of setTimeout when the API is not available

The "fps" option is also removed here, since it is now timed by the browser itself. It is by default equivalent to about 60 fps.

(updated, let me know if I have missed anything)