diff --git a/springy.js b/springy.js index c7c9c9d..51d313a 100644 --- a/springy.js +++ b/springy.js @@ -498,11 +498,7 @@ if (onRenderStart !== undefined) { onRenderStart(); } Springy.requestAnimationFrame(function step() { - t.applyCoulombsLaw(); - t.applyHookesLaw(); - t.attractToCentre(); - t.updateVelocity(0.03); - t.updatePosition(0.03); + t.tick(0.03); if (render !== undefined) { render(); @@ -522,6 +518,14 @@ this._stop = true; } + Layout.ForceDirected.prototype.tick = function(timestep) { + this.applyCoulombsLaw(); + this.applyHookesLaw(); + this.attractToCentre(); + this.updateVelocity(timestep); + this.updatePosition(timestep); + }; + // Find the nearest point to a particular position Layout.ForceDirected.prototype.nearest = function(pos) { var min = {node: null, point: null, distance: null};