Skip to content

Instantly share code, notes, and snippets.

@gladchinda
Created April 30, 2018 16:36
Show Gist options
  • Save gladchinda/d7ccc385d561d8f52a95c40cdbc0aac8 to your computer and use it in GitHub Desktop.
Save gladchinda/d7ccc385d561d8f52a95c40cdbc0aac8 to your computer and use it in GitHub Desktop.
// METHOD 1: Using if/else statements
let requestAnimFrame = null;
if (window.requestAnimationFrame) {
requestAnimFrame = window.requestAnimationFrame;
}
else if (window.webkitRequestAnimationFrame) {
requestAnimFrame = window.webkitRequestAnimationFrame;
}
else if (window.mozRequestAnimationFrame) {
requestAnimFrame = window.mozRequestAnimationFrame;
}
// METHOD 2: Using short-circuiting
const requestAnimFrame2 = (
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
null
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment