From 760c3e92458d92a084b7b16c705b53abe184f7dc Mon Sep 17 00:00:00 2001 From: AlexDM0 Date: Wed, 3 Jun 2015 11:34:03 +0200 Subject: [PATCH] changed autoResize to only draw when change is detected. --- lib/network/modules/Canvas.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/network/modules/Canvas.js b/lib/network/modules/Canvas.js index f052ef9f..739f3568 100644 --- a/lib/network/modules/Canvas.js +++ b/lib/network/modules/Canvas.js @@ -57,7 +57,12 @@ class Canvas { if (this.options.autoResize === true) { // automatically adapt to a changing size of the browser. this._cleanUp(); - this.resizeTimer = setInterval(() => {this.setSize(); this.body.emitter.emit("_requestRedraw");}, 1000); + this.resizeTimer = setInterval(() => { + let changed = this.setSize(); + if (changed === true) { + this.body.emitter.emit("_requestRedraw"); + } + }, 1000); this.resizeFunction = this._onResize.bind(this); util.addEventListener(window,'resize',this.resizeFunction); } @@ -228,6 +233,8 @@ class Canvas { if (emitEvent === true) { this.body.emitter.emit('resize', {width:this.frame.canvas.width / this.pixelRatio, height:this.frame.canvas.height / this.pixelRatio, oldWidth: oldWidth / this.pixelRatio, oldHeight: oldHeight / this.pixelRatio}); } + + return emitEvent; };