From 8218a8e4c7550264359c107f1537678b0502ad71 Mon Sep 17 00:00:00 2001 From: Alex de Mulder Date: Wed, 19 Mar 2014 11:09:03 +0100 Subject: [PATCH] added updateCalculationNodes to the remove node function to fix bug reported by #68 --- dist/vis.js | 25 +++++++++++++++---------- src/graph/Edge.js | 28 ++++++++++++++++------------ src/graph/Graph.js | 1 + 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/dist/vis.js b/dist/vis.js index 4771003e..da418db2 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -10643,18 +10643,22 @@ Edge.prototype.draw = function(ctx) { * @return {boolean} True if location is located on the edge */ Edge.prototype.isOverlappingWith = function(obj) { - var distMax = 10; + if (this.connected == true) { + var distMax = 10; + var xFrom = this.from.x; + var yFrom = this.from.y; + var xTo = this.to.x; + var yTo = this.to.y; + var xObj = obj.left; + var yObj = obj.top; - var xFrom = this.from.x; - var yFrom = this.from.y; - var xTo = this.to.x; - var yTo = this.to.y; - var xObj = obj.left; - var yObj = obj.top; + var dist = this._getDistanceToEdge(xFrom, yFrom, xTo, yTo, xObj, yObj); - var dist = this._getDistanceToEdge(xFrom, yFrom, xTo, yTo, xObj, yObj); - - return (dist < distMax); + return (dist < distMax); + } + else { + return false + } }; @@ -17318,6 +17322,7 @@ Graph.prototype._removeNodes = function(ids) { delete nodes[id]; } this._updateNodeIndexList(); + this._updateCalculationNodes(); this._reconnectEdges(); this._updateSelection(); this._updateValueRange(nodes); diff --git a/src/graph/Edge.js b/src/graph/Edge.js index f748455b..12fd5672 100644 --- a/src/graph/Edge.js +++ b/src/graph/Edge.js @@ -216,18 +216,22 @@ Edge.prototype.draw = function(ctx) { * @return {boolean} True if location is located on the edge */ Edge.prototype.isOverlappingWith = function(obj) { - var distMax = 10; - - var xFrom = this.from.x; - var yFrom = this.from.y; - var xTo = this.to.x; - var yTo = this.to.y; - var xObj = obj.left; - var yObj = obj.top; - - var dist = this._getDistanceToEdge(xFrom, yFrom, xTo, yTo, xObj, yObj); - - return (dist < distMax); + if (this.connected == true) { + var distMax = 10; + var xFrom = this.from.x; + var yFrom = this.from.y; + var xTo = this.to.x; + var yTo = this.to.y; + var xObj = obj.left; + var yObj = obj.top; + + var dist = this._getDistanceToEdge(xFrom, yFrom, xTo, yTo, xObj, yObj); + + return (dist < distMax); + } + else { + return false + } }; diff --git a/src/graph/Graph.js b/src/graph/Graph.js index ea3b0f48..50f70cbd 100644 --- a/src/graph/Graph.js +++ b/src/graph/Graph.js @@ -1322,6 +1322,7 @@ Graph.prototype._removeNodes = function(ids) { delete nodes[id]; } this._updateNodeIndexList(); + this._updateCalculationNodes(); this._reconnectEdges(); this._updateSelection(); this._updateValueRange(nodes);