From b56d18d6a408721a76e750e9ebbd2a00b2ec4e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Wed, 27 Jan 2016 13:02:50 +0100 Subject: [PATCH] Override DomEvent.requestAnimationFrame() in Node.js to avoid setInterval() timers --- src/export.js | 2 ++ src/node/extend.js | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/export.js b/src/export.js index 6462dae4..d0f4695c 100644 --- a/src/export.js +++ b/src/export.js @@ -22,6 +22,8 @@ paper = new (PaperScope.inject(Base.exports, { Base: Base, Numerical: Numerical, Key: Key, + DomEvent: DomEvent, + DomElement: DomElement, // Export jsdom document and window too, for Node.js document: document, window: window diff --git a/src/node/extend.js b/src/node/extend.js index 7928f67f..542aa65b 100644 --- a/src/node/extend.js +++ b/src/node/extend.js @@ -71,6 +71,11 @@ module.exports = function(paper) { Canvas: '#createCanvas' }); + // Override requestAnimationFrame() to avoid setInterval() timers. + paper.DomEvent.requestAnimationFrame = function(callback) { + process.nextTick(callback); + }; + // Node.js based image exporting code. paper.CanvasView.inject({ // DOCS: CanvasView#exportFrames(param);