From a81b00e130de6453b1871de5b93101e983cc2dc1 Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 30 Aug 2019 22:01:49 +0200 Subject: [PATCH] fix link map zoom after reload and some tweaks to springy --- db/demo.tar | Bin 500736 -> 506368 bytes libraries/springy.js | 5 +++-- src/public/javascripts/services/link_map.js | 10 ++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/db/demo.tar b/db/demo.tar index fde6a83ef64c4eac115d2cf84a0cab6efcb412c8..4edf70636408455281969ad245c4272db430aa5e 100644 GIT binary patch delta 7800 zcmcIpYiu0V7497;yN=^LdE`aS?F7hc*Piz{_Qq*q2gk7!huBFV0mAI=tatG4&SqxT ziHU-vAc6|50~(TnsuD;@4OJ=paLV>aB|@vJv_eSGs;UH{pwd4es478KP$hcq%+Ac+ zga+s%l9lz|`<;6p-+A2YQ?GQK`ncoK(`y7lQf17GvM30uq>2LOcwP`C{0+|2hEaYF zp>vG;(8a~>%1cY#y-Qo&bW7XDilbWu+_ZTAysE*W8W;$KAJfk%hJHl1t0n&p(je>RZXV z#cfZWau;7XN`7${w=H+~jx2Y%7ZTsSfhb=34>rG3X!UN#2+z&EymX^C*MTx~pMP*sK(cGL_SXN}fh^{H3blLfEIPJYrLp6`ja=I`_Ofnu4-RfrYQFHmvpUCt7f|3v$yFMWM4zRz16hJ znnOYvEX>`4{_J_{P?z`Xb?6Q6`|Hu)XWBB=KA$CK&B0p9HnHgxbqnjqwQ{wj+d!yE z9cMILwDiIjcCBTaPS?QB3Rm5BYv!iJyNzKmVfDp#l$Nz3bY&N8Z`0I+@8+B7a3rO8Ye z0nIe@?(!A%ZRrY(`Oj_oIws9PA^z`e%9|K65tp=DC2vg!mVGtDX8wJ&a1`Uvk$w>L z{1=4r>zLeR@eCD4pFvOv2I_1}r<~Zrc zopjciVEe|Z8t5`stT`}&-~q$VnNxa1Q@noE${H|i;RAZn$dz>Pz<_QW6BWN>_ux#< z%&(SX$Zd z6(n7pqG9EUh=MVt<3g=en#N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ERKt7e zNppXK>7CK2Amiphed#A@BUn5jAcDS`E-W{|AY`Q5mw~@cfE+8H0O!($rSm}C8(1>a z=JouibfMb#4Sl+bX50o)t3FLn7_^T~&T8|sbYV#X#4ctn`n4CH~;)ws_jMUO0#S^1EghX#O-8RkB&2rtVNk0dcgGA1xQ3FD zI_#0$!yn7vMYlesR(``hX@FXARw#Syi5!JU=<9I%AU^Pv>nE{Fl!`_6xO!LbcFnG? zTP8`Rhd5@slO%npqZH8r8&MF@Mdcs?`jWQU@~YAAl2t>{F8&-v`XS-Hj66({Sa3F% zqXdaBBo)XOh+Bu{2%ppT>fOhM6j5zjjv{DxI-ZWVe5`AMiO_9JB)(l)IqBH@Ij=u5C!cgFmOf#Yl;ioWV53n@-c8)gaiLwCm92bQKJJHXqv R5E#B}CE01%JMX!5{|A5zXgvS` diff --git a/libraries/springy.js b/libraries/springy.js index a1e8d65f4..65ad9fecf 100644 --- a/libraries/springy.js +++ b/libraries/springy.js @@ -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)); } }); }); diff --git a/src/public/javascripts/services/link_map.js b/src/public/javascripts/services/link_map.js index bacf44490..04b5af043 100644 --- a/src/public/javascripts/services/link_map.js +++ b/src/public/javascripts/services/link_map.js @@ -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); }