Created
April 30, 2018 16:36
-
-
Save gladchinda/d7ccc385d561d8f52a95c40cdbc0aac8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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