forked from ilikecats/papercats
Fix global var issue
This commit is contained in:
parent
454fc98865
commit
d7f1af47e2
@ -16,10 +16,18 @@ client.renderer = require("./game-renderer.js");
|
|||||||
// window.requestAnimationFrame = function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {
|
// window.requestAnimationFrame = function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {
|
||||||
// window.setTimeout( callback, 1000 / 60 );
|
// window.setTimeout( callback, 1000 / 60 );
|
||||||
// };
|
// };
|
||||||
var window, requestAnimationFrame;
|
var hasWindow;
|
||||||
|
try {
|
||||||
|
window.document;
|
||||||
|
hasWindow = true;
|
||||||
|
} catch (e) {
|
||||||
|
hasWindow = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var requestAnimationFrame;
|
||||||
if ( !requestAnimationFrame ) {
|
if ( !requestAnimationFrame ) {
|
||||||
requestAnimationFrame = ( function() {
|
requestAnimationFrame = ( function() {
|
||||||
if (window) {
|
if (hasWindow) {
|
||||||
return window.requestAnimationFrame ||
|
return window.requestAnimationFrame ||
|
||||||
window.webkitRequestAnimationFrame ||
|
window.webkitRequestAnimationFrame ||
|
||||||
window.mozRequestAnimationFrame ||
|
window.mozRequestAnimationFrame ||
|
||||||
|
@ -33,10 +33,18 @@ var grid = new Grid(consts.GRID_SIZE, function(row, col, before, after) {
|
|||||||
// window.setTimeout( callback, 1000 / 60 );
|
// window.setTimeout( callback, 1000 / 60 );
|
||||||
// };
|
// };
|
||||||
|
|
||||||
var window, requestAnimationFrame;
|
var hasWindow;
|
||||||
|
try {
|
||||||
|
window.document;
|
||||||
|
hasWindow = true;
|
||||||
|
} catch (e) {
|
||||||
|
hasWindow = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var requestAnimationFrame;
|
||||||
if ( !requestAnimationFrame ) {
|
if ( !requestAnimationFrame ) {
|
||||||
requestAnimationFrame = ( function() {
|
requestAnimationFrame = ( function() {
|
||||||
if (window) {
|
if (hasWindow) {
|
||||||
return window.requestAnimationFrame ||
|
return window.requestAnimationFrame ||
|
||||||
window.webkitRequestAnimationFrame ||
|
window.webkitRequestAnimationFrame ||
|
||||||
window.mozRequestAnimationFrame ||
|
window.mozRequestAnimationFrame ||
|
||||||
|
@ -118,10 +118,18 @@ client.renderer = require("./game-renderer.js");
|
|||||||
// window.requestAnimationFrame = function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {
|
// window.requestAnimationFrame = function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {
|
||||||
// window.setTimeout( callback, 1000 / 60 );
|
// window.setTimeout( callback, 1000 / 60 );
|
||||||
// };
|
// };
|
||||||
var window, requestAnimationFrame;
|
var hasWindow;
|
||||||
|
try {
|
||||||
|
window.document;
|
||||||
|
hasWindow = true;
|
||||||
|
} catch (e) {
|
||||||
|
hasWindow = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var requestAnimationFrame;
|
||||||
if ( !requestAnimationFrame ) {
|
if ( !requestAnimationFrame ) {
|
||||||
requestAnimationFrame = ( function() {
|
requestAnimationFrame = ( function() {
|
||||||
if (window) {
|
if (hasWindow) {
|
||||||
return window.requestAnimationFrame ||
|
return window.requestAnimationFrame ||
|
||||||
window.webkitRequestAnimationFrame ||
|
window.webkitRequestAnimationFrame ||
|
||||||
window.mozRequestAnimationFrame ||
|
window.mozRequestAnimationFrame ||
|
||||||
@ -8687,10 +8695,18 @@ var grid = new Grid(consts.GRID_SIZE, function(row, col, before, after) {
|
|||||||
// window.setTimeout( callback, 1000 / 60 );
|
// window.setTimeout( callback, 1000 / 60 );
|
||||||
// };
|
// };
|
||||||
|
|
||||||
var window, requestAnimationFrame;
|
var hasWindow;
|
||||||
|
try {
|
||||||
|
window.document;
|
||||||
|
hasWindow = true;
|
||||||
|
} catch (e) {
|
||||||
|
hasWindow = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var requestAnimationFrame;
|
||||||
if ( !requestAnimationFrame ) {
|
if ( !requestAnimationFrame ) {
|
||||||
requestAnimationFrame = ( function() {
|
requestAnimationFrame = ( function() {
|
||||||
if (window) {
|
if (hasWindow) {
|
||||||
return window.requestAnimationFrame ||
|
return window.requestAnimationFrame ||
|
||||||
window.webkitRequestAnimationFrame ||
|
window.webkitRequestAnimationFrame ||
|
||||||
window.mozRequestAnimationFrame ||
|
window.mozRequestAnimationFrame ||
|
||||||
|
Loading…
Reference in New Issue
Block a user