Browse Source

changed autoResize to only draw when change is detected.

flowchartTest
AlexDM0 9 years ago
parent
commit
760c3e9245
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      lib/network/modules/Canvas.js

+ 8
- 1
lib/network/modules/Canvas.js View File

@ -57,7 +57,12 @@ class Canvas {
if (this.options.autoResize === true) { if (this.options.autoResize === true) {
// automatically adapt to a changing size of the browser. // automatically adapt to a changing size of the browser.
this._cleanUp(); 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); this.resizeFunction = this._onResize.bind(this);
util.addEventListener(window,'resize',this.resizeFunction); util.addEventListener(window,'resize',this.resizeFunction);
} }
@ -228,6 +233,8 @@ class Canvas {
if (emitEvent === true) { 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}); 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;
}; };

Loading…
Cancel
Save