Fix global var issue

This commit is contained in:
Henry Wang 2017-09-04 17:59:35 -05:00
parent 454fc98865
commit d7f1af47e2
3 changed files with 40 additions and 8 deletions

View File

@ -16,10 +16,18 @@ client.renderer = require("./game-renderer.js");
// window.requestAnimationFrame = function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {
// window.setTimeout( callback, 1000 / 60 );
// };
var window, requestAnimationFrame;
var hasWindow;
try {
window.document;
hasWindow = true;
} catch (e) {
hasWindow = false;
}
var requestAnimationFrame;
if ( !requestAnimationFrame ) {
requestAnimationFrame = ( function() {
if (window) {
if (hasWindow) {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||

View File

@ -33,10 +33,18 @@ var grid = new Grid(consts.GRID_SIZE, function(row, col, before, after) {
// window.setTimeout( callback, 1000 / 60 );
// };
var window, requestAnimationFrame;
var hasWindow;
try {
window.document;
hasWindow = true;
} catch (e) {
hasWindow = false;
}
var requestAnimationFrame;
if ( !requestAnimationFrame ) {
requestAnimationFrame = ( function() {
if (window) {
if (hasWindow) {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||

View File

@ -118,10 +118,18 @@ client.renderer = require("./game-renderer.js");
// window.requestAnimationFrame = function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {
// window.setTimeout( callback, 1000 / 60 );
// };
var window, requestAnimationFrame;
var hasWindow;
try {
window.document;
hasWindow = true;
} catch (e) {
hasWindow = false;
}
var requestAnimationFrame;
if ( !requestAnimationFrame ) {
requestAnimationFrame = ( function() {
if (window) {
if (hasWindow) {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
@ -8687,10 +8695,18 @@ var grid = new Grid(consts.GRID_SIZE, function(row, col, before, after) {
// window.setTimeout( callback, 1000 / 60 );
// };
var window, requestAnimationFrame;
var hasWindow;
try {
window.document;
hasWindow = true;
} catch (e) {
hasWindow = false;
}
var requestAnimationFrame;
if ( !requestAnimationFrame ) {
requestAnimationFrame = ( function() {
if (window) {
if (hasWindow) {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||