Game Development Reference
In-Depth Information
would mean to use the function where available and use a fallback where it isn't
available.
window.requestAnimationFrame = (function() {
// Check if the unprefixed version is present
if (window.requestAnimationFrame) {
return window.requestAnimationFrame;
}
// Check for WebKit based implementation
if (window.webkitRequestAnimationFrame) {
return window.webkitRequestAnimationFrame;
}
// Check for Mozilla based implementation
if (window.mozRequestAnimationFrame) {
return window.mozRequestAnimationFrame;
}
// Check for Microsoft based implementation
if (window.msRequestAnimationFrame) {
return window.msRequestAnimationFrame;
}
// Check for Opera based implementation
if (window.oRequestAnimationFrame) {
return window.oRequestAnimationFrame;
}
// If nothing else, simulate the
functionality with
// something similar - a custom timer
return function(callback) {
var fps = 1000 / 60;
var timestamp = Date.now();
setTimeout(function(){
Search WWH ::




Custom Search