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

Simplify the requestAnimationFrame backwards compatibility code #85

Open
fvsch opened this issue Nov 6, 2017 · 1 comment
Open

Simplify the requestAnimationFrame backwards compatibility code #85

fvsch opened this issue Nov 6, 2017 · 1 comment
Assignees

Comments

@fvsch
Copy link

fvsch commented Nov 6, 2017

For simplicity's sake, and since unprefixed rAF have been in the wild for a while, maybe simplify:

    // check what requestAnimationFrame to use, and if
    // it's not supported, use the onscroll event
    var loop = window.requestAnimationFrame ||
      window.webkitRequestAnimationFrame ||
      window.mozRequestAnimationFrame ||
      window.msRequestAnimationFrame ||
      window.oRequestAnimationFrame ||
function(callback){ setTimeout(callback, 1000 / 60); };

for:

    // check what requestAnimationFrame to use, and if
    // it's not supported, use the onscroll event
    var loop = window.requestAnimationFrame || function(callback){ setTimeout(callback, 16); };

Also it looks like the onscroll event is not used, so the comment should be fixed?

Browser support:
https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Browser_compatibility

  • Firefox 23
  • Chrome 24, Opera 15
  • IE 10 (note that window.msRequestAnimationFrame never existed anyway)
  • Safari 6.1

If support for Safari 6.0 is a goal, maybe keep only the webkit prefix.

@moeamaya moeamaya self-assigned this Dec 5, 2017
@yairEO
Copy link

yairEO commented Mar 26, 2018

Note that it is best practice to write 1000 / 60 and not simply 16, which doesn't mean much by itself, and is also rounded...

This has been addressed in my fork of the project

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

No branches or pull requests

3 participants