diff --git a/src/link.js b/src/link.js index cd979f2..af7f53f 100644 --- a/src/link.js +++ b/src/link.js @@ -15,7 +15,7 @@ export default function() { nodes, stableVelocity = 0, stableVeloHandler = null, - latestVelocityDiff = 0 + latestVelocityDiff = 0, iterations = 1; function force(alpha) { @@ -95,7 +95,7 @@ export default function() { force.latestAccel = function () { return latestVelocityDiff; }; - + force.onStableVelo = function (_) { return arguments.length ? (stableVeloHandler = _, force) : stableVeloHandler; }; diff --git a/src/stress.js b/src/stress.js index aa1a5bd..6d75880 100644 --- a/src/stress.js +++ b/src/stress.js @@ -7,7 +7,7 @@ export function getStress(nodes, distance) { let sumDiffSq = 0 let sumLowDDistSq = 0; - for (let j = nodes.length-1; j >= 1; j++) { + for (let j = nodes.length-1; j >= 1; j--) { for (let i = 0; i < j; i++) { let source = nodes[i], target = nodes[j]; let lowDDist = Math.hypot(target.x - source.x, target.y - source.y);