fix link map zoom after reload and some tweaks to springy

This commit is contained in:
zadam 2019-08-30 22:01:49 +02:00
parent d4e27c1b76
commit a81b00e130
3 changed files with 7 additions and 8 deletions

Binary file not shown.

View file

@ -417,11 +417,12 @@
{
var d = point1.p.subtract(point2.p);
var distance = d.magnitude() + 0.1; // avoid massive forces at small distances (and divide by zero)
var direction = d.normalise();
// apply force to each end point
point1.applyForce(direction.multiply(this.repulsion).divide(distance * distance * 0.5));
point2.applyForce(direction.multiply(this.repulsion).divide(distance * distance * -0.5));
point1.applyForce(direction.multiply(this.repulsion).divide(distance * distance * distance * 0.5));
point2.applyForce(direction.multiply(this.repulsion).divide(distance * distance * distance * -0.5));
}
});
});

View file

@ -65,8 +65,9 @@ export default class LinkMap {
graph,
// param explanation here: https://github.com/dhotson/springy/issues/58
400.0, // Spring stiffness
400.0, // Node repulsion
0.15 // Damping
600.0, // Node repulsion
0.15, // Damping
0.1 // min energy threshold
);
const getNoteBox = noteId => {
@ -163,9 +164,6 @@ export default class LinkMap {
);
this.renderer.start();
// long rendering is annoying and by 3rd seconds the basic layout should be finished
setTimeout(() => this.renderer.stop(), 3000);
}
moveToCenterOfElement(element) {
@ -213,7 +211,7 @@ export default class LinkMap {
this.$linkMapContainer.empty();
// reset zoom/pan
this.pzInstance.zoomTo(0, 0, this.options.zoom);
this.pzInstance.zoomAbs(0, 0, this.options.zoom);
this.pzInstance.moveTo(0, 0);
}