From ad55b85912b34df4c74b20502fe910b220e6d7ed Mon Sep 17 00:00:00 2001 From: liabru Date: Sat, 15 Aug 2015 20:38:40 +0100 Subject: [PATCH] fix Matter.Runner for node --- src/core/Runner.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/Runner.js b/src/core/Runner.js index 82a1023..138435c 100644 --- a/src/core/Runner.js +++ b/src/core/Runner.js @@ -16,17 +16,17 @@ var Runner = {}; (function() { - if (typeof window === 'undefined') { - // TODO: support Runner on non-browser environments. - return; - } + var _requestAnimationFrame, + _cancelAnimationFrame; - var _requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame + if (typeof window !== 'undefined') { + _requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || function(callback){ window.setTimeout(function() { callback(Common.now()); }, 1000 / 60); }; - var _cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame + _cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.msCancelAnimationFrame; + } /** * Creates a new Runner. The options parameter is an object that specifies any properties you wish to override the defaults. @@ -163,7 +163,7 @@ var Runner = {}; Events.trigger(runner, 'afterUpdate', event); // render - if (engine.render) { + if (engine.render && engine.render.controller) { Events.trigger(runner, 'beforeRender', event); Events.trigger(engine, 'beforeRender', event); // @deprecated