diff --git a/HISTORY.md b/HISTORY.md index 91eedb3f..0cef97d7 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -8,6 +8,7 @@ http://visjs.org - Fixed bug where an edge that was not connected would crash the layout algorithms. - Fixed bug where a box shape could not be drawn outside of the viewable area. - Fixed bug where dragging a node that is not a control node during edit edge mode would throw an error. +- Made autoscaling on container size change pick the lowest between delta height and delta width. ## 2015-09-14, version 4.8.2 diff --git a/dist/vis.js b/dist/vis.js index 171658e6..ec085ffb 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -36374,6 +36374,7 @@ return /******/ (function(modules) { // webpackBootstrap var pixelRatio = arguments.length <= 0 || arguments[0] === undefined ? this.pixelRatio : arguments[0]; this.cameraState.previousWidth = this.frame.canvas.width / pixelRatio; + this.cameraState.previousHeight = this.frame.canvas.height / pixelRatio; this.cameraState.scale = this.body.view.scale; this.cameraState.position = this.DOMtoCanvas({ x: 0.5 * this.frame.canvas.width / pixelRatio, y: 0.5 * this.frame.canvas.height / pixelRatio }); } @@ -36387,7 +36388,7 @@ return /******/ (function(modules) { // webpackBootstrap value: function _setCameraState() { if (this.cameraState.scale !== undefined && this.frame.canvas.clientWidth !== 0 && this.frame.canvas.clientHeight !== 0 && this.pixelRatio !== 0 && this.cameraState.previousWidth > 0) { - this.body.view.scale = this.cameraState.scale * (this.frame.canvas.width / this.pixelRatio / this.cameraState.previousWidth); + this.body.view.scale = this.cameraState.scale * Math.min(this.frame.canvas.width / this.pixelRatio / this.cameraState.previousWidth, this.frame.canvas.height / this.pixelRatio / this.cameraState.previousHeight); // this comes from the view module. var currentViewCenter = this.DOMtoCanvas({ diff --git a/lib/network/modules/Canvas.js b/lib/network/modules/Canvas.js index f13de18a..74e33a72 100644 --- a/lib/network/modules/Canvas.js +++ b/lib/network/modules/Canvas.js @@ -89,6 +89,7 @@ class Canvas { */ _getCameraState(pixelRatio = this.pixelRatio) { this.cameraState.previousWidth = this.frame.canvas.width / pixelRatio; + this.cameraState.previousHeight = this.frame.canvas.height / pixelRatio; this.cameraState.scale = this.body.view.scale; this.cameraState.position = this.DOMtoCanvas({x: 0.5 * this.frame.canvas.width / pixelRatio, y: 0.5 * this.frame.canvas.height / pixelRatio}); } @@ -104,7 +105,7 @@ class Canvas { this.pixelRatio !== 0 && this.cameraState.previousWidth > 0) { - this.body.view.scale = this.cameraState.scale * ((this.frame.canvas.width / this.pixelRatio) / this.cameraState.previousWidth); + this.body.view.scale = this.cameraState.scale * Math.min((this.frame.canvas.width / this.pixelRatio) / this.cameraState.previousWidth,(this.frame.canvas.height / this.pixelRatio) / this.cameraState.previousHeight); // this comes from the view module. var currentViewCenter = this.DOMtoCanvas({