diff --git a/lib/network/modules/CanvasRenderer.js b/lib/network/modules/CanvasRenderer.js index 06bbfbd4..5c749449 100644 --- a/lib/network/modules/CanvasRenderer.js +++ b/lib/network/modules/CanvasRenderer.js @@ -149,17 +149,20 @@ class CanvasRenderer { // // This is not something that will happen in normal operation, but we still need // to take it into account. - if (window === undefined) return; + // + var myWindow = window; // Grab a reference to reduce the possibility that 'window' is reset + // while running this method. + if (myWindow === undefined) return; let timer; if (this.requiresTimeout === true) { // wait given number of milliseconds and perform the animation step function - timer = window.setTimeout(callback, delay); + timer = myWindow.setTimeout(callback, delay); } else { - if (window.requestAnimationFrame) { - timer = window.requestAnimationFrame(callback); + if (myWindow.requestAnimationFrame) { + timer = myWindow.requestAnimationFrame(callback); } }