Skip to content

Instantly share code, notes, and snippets.

@jed
Forked from 140bytes/LICENSE.txt
Created May 29, 2011 10:03
Show Gist options
  • Save jed/997619 to your computer and use it in GitHub Desktop.
Save jed/997619 to your computer and use it in GitHub Desktop.
polyfill requestAnimationFrame across browsers
// inspired by https://twitter.com/WebReflection/status/74521550245732352
function(
a, // current cursor
b // placeholder
){
while( // while
a-- && // the cursor is still positivel
!( // and there is nothing
b = // to set b to
this[ // on the property of the global object
"oR0msR0mozR0webkitR0r" // which starts with the item in this list
.split(0) // (split on 0s)
[a] + // at the cursor position
"equestAnimationFrame" // plus the suffix,
] // and stop when something is found.
)
);
return b // return either the found method
|| function( // or otherwise a function
a // that takes a function
){
setTimeout( // and calls
a, // it in
15 // 15ms.
)
}
}(
5 // iterate for the 5 items in the list.
)
function(a,b){while(a--&&!(b=this["oR0msR0mozR0webkitR0r".split(0)[a]+"equestAnimationFrame"]));return b||function(a){setTimeout(a,15)}}(5)
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "requestAnimationFrame",
"description": "polyfill requestAnimationFrame across browsers",
"keywords": [
"animation",
"requestAnimationFrame"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment