Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RequestAnimationFrame instead of setTimeout #1

Open
mostlygeek opened this issue Jan 30, 2013 · 3 comments
Open

Use RequestAnimationFrame instead of setTimeout #1

mostlygeek opened this issue Jan 30, 2013 · 3 comments

Comments

@mostlygeek
Copy link
Contributor

Using RAF would make drawing more efficient and sync up the draw with the refresh of the screen (60hz).

Since cross browser support sucks, use the HTML5 RAF polyfill:

https://gist.github.com/1579671

@mikewoodworth
Copy link
Member

are there any release browsers using RequestAnimationFrame yet? it's on my internal feature list (which reminds me, we should probably port those here), but my impression was this wasn't very pressing ATM.

@mikewoodworth
Copy link
Member

ok, just looked, and it seems I'm a bit behind. Yeah, this should be done.

@mostlygeek
Copy link
Contributor Author

You need the polyfill to support this.

Here's more information: https://developer.mozilla.org/en-US/docs/DOM/window.requestAnimationFrame

tl;dr

  • IE9 / Opera? need to use setTimeout
  • Webkit/Gecko has prefixed RAF functions

The main change would be to work the framerate code in there. Since RAF is called at 60fps. I did something similar in my anim8 library so it would be really easy to make this happen.

Let me see if I can do a Pull Request for you later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants