joewalnes/smoothie — pull request #28 by imrehg (2012-12-06 14:53:00+00:00)
Title: switch to requestAnimationFrame for rendering

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
one 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.