diff --git a/dist/vis.js b/dist/vis.js index ba580c59..3caaefbf 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -5,7 +5,7 @@ * A dynamic, browser-based visualization library. * * @version 0.7.2-SNAPSHOT - * @date 2014-03-27 + * @date 2014-03-31 * * @license * Copyright (C) 2011-2014 Almende B.V, http://almende.com @@ -16308,6 +16308,9 @@ Graph.prototype._getRange = function() { if (maxY < (node.y)) {maxY = node.y;} } } + if (minX == 1e9 && maxX == -1e9 && minY == 1e9 && maxY == -1e9) { + minY = 0, maxY = 0, minX = 0, maxX = 0; + } return {minX: minX, maxX: maxX, minY: minY, maxY: maxY}; }; @@ -17018,6 +17021,7 @@ Graph.prototype._zoom = function(scale, pointer) { this.updateClustersDefault(); this._redraw(); + return scale; }; @@ -17795,11 +17799,13 @@ Graph.prototype._discreteStepNodes = function() { var interval = this.physicsDiscreteStepsize; var nodes = this.nodes; var nodeId; + var nodesPresent = false; if (this.constants.maxVelocity > 0) { for (nodeId in nodes) { if (nodes.hasOwnProperty(nodeId)) { nodes[nodeId].discreteStepLimited(interval, this.constants.maxVelocity); + nodesPresent = true; } } } @@ -17807,15 +17813,19 @@ Graph.prototype._discreteStepNodes = function() { for (nodeId in nodes) { if (nodes.hasOwnProperty(nodeId)) { nodes[nodeId].discreteStep(interval); + nodesPresent = true; } } } - var vminCorrected = this.constants.minVelocity / Math.max(this.scale,0.05); - if (vminCorrected > 0.5*this.constants.maxVelocity) { - this.moving = true; - } - else { - this.moving = this._isMoving(vminCorrected); + + if (nodesPresent == true) { + var vminCorrected = this.constants.minVelocity / Math.max(this.scale,0.05); + if (vminCorrected > 0.5*this.constants.maxVelocity) { + this.moving = true; + } + else { + this.moving = this._isMoving(vminCorrected); + } } }; diff --git a/src/graph/Graph.js b/src/graph/Graph.js index 28ddfa39..b69dfe69 100644 --- a/src/graph/Graph.js +++ b/src/graph/Graph.js @@ -303,6 +303,9 @@ Graph.prototype._getRange = function() { if (maxY < (node.y)) {maxY = node.y;} } } + if (minX == 1e9 && maxX == -1e9 && minY == 1e9 && maxY == -1e9) { + minY = 0, maxY = 0, minX = 0, maxX = 0; + } return {minX: minX, maxX: maxX, minY: minY, maxY: maxY}; }; @@ -1013,6 +1016,7 @@ Graph.prototype._zoom = function(scale, pointer) { this.updateClustersDefault(); this._redraw(); + return scale; }; @@ -1790,11 +1794,13 @@ Graph.prototype._discreteStepNodes = function() { var interval = this.physicsDiscreteStepsize; var nodes = this.nodes; var nodeId; + var nodesPresent = false; if (this.constants.maxVelocity > 0) { for (nodeId in nodes) { if (nodes.hasOwnProperty(nodeId)) { nodes[nodeId].discreteStepLimited(interval, this.constants.maxVelocity); + nodesPresent = true; } } } @@ -1802,15 +1808,19 @@ Graph.prototype._discreteStepNodes = function() { for (nodeId in nodes) { if (nodes.hasOwnProperty(nodeId)) { nodes[nodeId].discreteStep(interval); + nodesPresent = true; } } } - var vminCorrected = this.constants.minVelocity / Math.max(this.scale,0.05); - if (vminCorrected > 0.5*this.constants.maxVelocity) { - this.moving = true; - } - else { - this.moving = this._isMoving(vminCorrected); + + if (nodesPresent == true) { + var vminCorrected = this.constants.minVelocity / Math.max(this.scale,0.05); + if (vminCorrected > 0.5*this.constants.maxVelocity) { + this.moving = true; + } + else { + this.moving = this._isMoving(vminCorrected); + } } };