Link add API
This commit is contained in:
@@ -15,6 +15,7 @@ export default function() {
|
||||
nodes,
|
||||
stableVelocity = 0,
|
||||
stableVeloHandler = null,
|
||||
latestVelocityDiff = 0
|
||||
iterations = 1;
|
||||
|
||||
function force(alpha) {
|
||||
@@ -54,6 +55,7 @@ export default function() {
|
||||
velocityDiff += Math.abs(Math.hypot(node.vx-node.oldvx, node.vy-node.oldvy));
|
||||
}
|
||||
velocityDiff /= n*(n-1);
|
||||
latestVelocityDiff = velocityDiff;
|
||||
|
||||
if(velocityDiff<stableVelocity){
|
||||
stableVeloHandler();
|
||||
@@ -90,6 +92,10 @@ export default function() {
|
||||
return arguments.length ? (distance = typeof _ === "function" ? _ : constant(+_), initializeDistance(), force) : distance;
|
||||
};
|
||||
|
||||
force.latestAccel = function () {
|
||||
return latestVelocityDiff;
|
||||
};
|
||||
|
||||
force.onStableVelo = function (_) {
|
||||
return arguments.length ? (stableVeloHandler = _, force) : stableVeloHandler;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user