diff options
author | Fraser Adams <fraser.adams@blueyonder.co.uk> | 2013-10-29 20:53:51 +0000 |
---|---|---|
committer | Fraser Adams <fraser.adams@blueyonder.co.uk> | 2013-10-29 20:53:51 +0000 |
commit | e37d142969386b92616383cf8616e3ca2d92c3af (patch) | |
tree | baa5145cf5948162776c4992652fa0ae74e65f81 /src/library_browser.js | |
parent | 7a902d9e4d79e370f44f94a9a7f7ed45ba3dfbb2 (diff) |
updated library_sockfs.js to make WebSocket a local var and updated library_browser.js to modify requestAnimationFrame to provide a fallback to setTimeout if window is undefined
Diffstat (limited to 'src/library_browser.js')
-rw-r--r-- | src/library_browser.js | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/library_browser.js b/src/library_browser.js index 5ec02eee..0d5bf6db 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -360,15 +360,19 @@ mergeInto(LibraryManager.library, { }, requestAnimationFrame: function(func) { - if (!window.requestAnimationFrame) { - window.requestAnimationFrame = window['requestAnimationFrame'] || - window['mozRequestAnimationFrame'] || - window['webkitRequestAnimationFrame'] || - window['msRequestAnimationFrame'] || - window['oRequestAnimationFrame'] || - window['setTimeout']; + if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js) + setTimeout(func, 1000/60); + } else { + if (!window.requestAnimationFrame) { + window.requestAnimationFrame = window['requestAnimationFrame'] || + window['mozRequestAnimationFrame'] || + window['webkitRequestAnimationFrame'] || + window['msRequestAnimationFrame'] || + window['oRequestAnimationFrame'] || + window['setTimeout']; + } + window.requestAnimationFrame(func); } - window.requestAnimationFrame(func); }, // generic abort-aware wrapper for an async callback @@ -782,11 +786,7 @@ mergeInto(LibraryManager.library, { } } else { Browser.mainLoop.scheduler = function() { - if (typeof window === 'undefined') { // requestAnimationFrame will fail if window is undefined (e.g. in Node.js) - setTimeout(Browser.mainLoop.runner, 1000/60); - } else { - Browser.requestAnimationFrame(Browser.mainLoop.runner); - } + Browser.requestAnimationFrame(Browser.mainLoop.runner); } } Browser.mainLoop.scheduler(); |