Browse Source

Fixed bug where the network could flicker when the pixelRatio is not integer.

flowchartTest
AlexDM0 9 years ago
parent
commit
1302a6b3e0
3 changed files with 2214 additions and 2203 deletions
  1. +1
    -0
      HISTORY.md
  2. +2201
    -2196
      dist/vis.js
  3. +12
    -7
      lib/network/modules/Canvas.js

+ 1
- 0
HISTORY.md View File

@ -28,6 +28,7 @@ http://visjs.org
- Fixed dataView support for storePositions. - Fixed dataView support for storePositions.
- Second click on node is no longer unselect. - Second click on node is no longer unselect.
- Added releaseFunction to openCluster. - Added releaseFunction to openCluster.
- Fixed bug where the network could flicker when the pixelRatio is not integer.
## 2015-05-28, version 4.1.0 ## 2015-05-28, version 4.1.0

+ 2201
- 2196
dist/vis.js
File diff suppressed because it is too large
View File


+ 12
- 7
lib/network/modules/Canvas.js View File

@ -208,8 +208,8 @@ class Canvas {
this.frame.canvas.style.width = '100%'; this.frame.canvas.style.width = '100%';
this.frame.canvas.style.height = '100%'; this.frame.canvas.style.height = '100%';
this.frame.canvas.width = this.frame.canvas.clientWidth * this.pixelRatio;
this.frame.canvas.height = this.frame.canvas.clientHeight * this.pixelRatio;
this.frame.canvas.width = Math.round(this.frame.canvas.clientWidth * this.pixelRatio);
this.frame.canvas.height = Math.round(this.frame.canvas.clientHeight * this.pixelRatio);
this.options.width = width; this.options.width = width;
this.options.height = height; this.options.height = height;
@ -220,18 +220,23 @@ class Canvas {
// this would adapt the width of the canvas to the width from 100% if and only if // this would adapt the width of the canvas to the width from 100% if and only if
// there is a change. // there is a change.
if (this.frame.canvas.width != this.frame.canvas.clientWidth * this.pixelRatio) {
this.frame.canvas.width = this.frame.canvas.clientWidth * this.pixelRatio;
if (this.frame.canvas.width != Math.round(this.frame.canvas.clientWidth * this.pixelRatio)) {
this.frame.canvas.width = Math.round(this.frame.canvas.clientWidth * this.pixelRatio);
emitEvent = true; emitEvent = true;
} }
if (this.frame.canvas.height != this.frame.canvas.clientHeight * this.pixelRatio) {
this.frame.canvas.height = this.frame.canvas.clientHeight * this.pixelRatio;
if (this.frame.canvas.height != Math.round(this.frame.canvas.clientHeight * this.pixelRatio)) {
this.frame.canvas.height = Math.round(this.frame.canvas.clientHeight * this.pixelRatio);
emitEvent = true; emitEvent = true;
} }
} }
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:Math.round(this.frame.canvas.width / this.pixelRatio),
height:Math.round(this.frame.canvas.height / this.pixelRatio),
oldWidth: Math.round(oldWidth / this.pixelRatio),
oldHeight: Math.round(oldHeight / this.pixelRatio)
});
} }
return emitEvent; return emitEvent;

Loading…
Cancel
Save