0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-23 09:26:51 -05:00

fix requestAnimationFrame polyfill for Matter.Runner, closes #252

This commit is contained in:
liabru 2016-06-26 20:38:06 +01:00
parent 34524651fb
commit 7c8f6ced5c

View file

@ -25,13 +25,26 @@ var Common = require('./Common');
if (typeof window !== 'undefined') {
_requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame
|| window.mozRequestAnimationFrame || window.msRequestAnimationFrame
|| function(callback){ window.setTimeout(function() { callback(Common.now()); }, 1000 / 60); };
|| window.mozRequestAnimationFrame || window.msRequestAnimationFrame;
_cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame
|| window.webkitCancelAnimationFrame || window.msCancelAnimationFrame;
}
if (!_requestAnimationFrame) {
var _frameTimeout;
_requestAnimationFrame = function(callback){
_frameTimeout = setTimeout(function() {
callback(Common.now());
}, 1000 / 60);
};
_cancelAnimationFrame = function() {
clearTimeout(_frameTimeout);
};
}
/**
* Creates a new Runner. The options parameter is an object that specifies any properties you wish to override the defaults.
* @method create