Merge pull request #63 from WebOnWebOff/master

Allow configuration of minimum energy threshold
This commit is contained in:
Dennis Hotson 2014-06-01 18:17:33 +10:00
commit 1d51239af1

View File

@ -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 {