From eb675cd7f64da1e5bdbf2cd3b151d7c3df3e12c3 Mon Sep 17 00:00:00 2001 From: Steven Pearce Date: Sun, 24 Jul 2016 12:11:31 +0100 Subject: [PATCH] Resolve issue almende/vis#1857 Perturbing the nodes was being performed on all nodes regardless of whether they were set as fixed. --- lib/network/modules/LayoutEngine.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/network/modules/LayoutEngine.js b/lib/network/modules/LayoutEngine.js index 78ab7f79..b068133a 100644 --- a/lib/network/modules/LayoutEngine.js +++ b/lib/network/modules/LayoutEngine.js @@ -234,8 +234,11 @@ class LayoutEngine { // perturb the nodes a little bit to force the physics to kick in let offset = 70; for (let i = 0; i < this.body.nodeIndices.length; i++) { - this.body.nodes[this.body.nodeIndices[i]].x += (0.5 - this.seededRandom())*offset; - this.body.nodes[this.body.nodeIndices[i]].y += (0.5 - this.seededRandom())*offset; + // Only perturb the nodes that aren't fixed + if (this.body.nodes[this.body.nodeIndices[i]].predefinedPosition === false) { + this.body.nodes[this.body.nodeIndices[i]].x += (0.5 - this.seededRandom())*offset; + this.body.nodes[this.body.nodeIndices[i]].y += (0.5 - this.seededRandom())*offset; + } } // uncluster all clusters