Allow configuration of minimum energy threshold

This commit is contained in:
'WebOnWebOff' 2014-05-20 17:18:00 +03:00
parent 28ca9cc5be
commit 50eed3e039

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 {