diff --git a/springy.js b/springy.js index 2304747..e2fc76b 100644 --- a/springy.js +++ b/springy.js @@ -325,11 +325,12 @@ // ----------- var Layout = Springy.Layout = {}; - Layout.ForceDirected = function(graph, stiffness, repulsion, damping) { + Layout.ForceDirected = function(graph, stiffness, repulsion, damping, minEnergyThreshold) { this.graph = graph; this.stiffness = stiffness; // spring stiffness constant this.repulsion = repulsion; // repulsion constant this.damping = damping; // velocity damping factor + this.minEnergyThreshold = minEnergyThreshold || 0.01; //threshold used to determine render stop this.nodePoints = {}; // keep track of points associated with nodes this.edgeSprings = {}; // keep track of springs associated with edges @@ -508,7 +509,7 @@ } // stop simulation when energy of the system goes below a threshold - if (t._stop || t.totalEnergy() < 0.01) { + if (t._stop || t.totalEnergy() < t.minEnergyThreshold) { t._started = false; if (onRenderStop !== undefined) { onRenderStop(); } } else {