Skip to content

Instantly share code, notes, and snippets.

@sushat4692
Created April 1, 2014 13:59
Show Gist options
  • Save sushat4692/9914517 to your computer and use it in GitHub Desktop.
Save sushat4692/9914517 to your computer and use it in GitHub Desktop.
requestAnimationFrame
// requestAnimationFrameを優先に、存在しなければsetTimeoutを取得する
var requestAnimationFrame = window.requestAnimationFrame
|| window.webkitRequestAnimationFrame
|| window.mozRequestAnimationFrame
|| window.setTimeout;
window.requestAnimationFrame = requestAnimationFrame;
function func() {
// 実行させたい何か
}
requestAnimationFrame( func, interval ); // intervalはsetTimeoutの時だけ利用されます
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment