microboard-temp 0.13.19 → 0.13.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54705,10 +54705,13 @@ class ForceGraphEngine {
54705
54705
  continue;
54706
54706
  const dx = s2.cx - s1.cx;
54707
54707
  const dy = s2.cy - s1.cy;
54708
- const distSq = dx * dx + dy * dy + this.SOFTENING_SQ;
54709
- const repMag = conf.FG_REPULSION / distSq;
54710
- const fx = dx * repMag;
54711
- const fy = dy * repMag;
54708
+ const centerDist = Math.sqrt(dx * dx + dy * dy) + 0.001;
54709
+ const r1 = Math.max(s1.w, s1.h) * 0.5;
54710
+ const r2 = Math.max(s2.w, s2.h) * 0.5;
54711
+ const edgeDist = Math.max(centerDist - r1 - r2, 1);
54712
+ const repMag = conf.FG_REPULSION / (edgeDist * edgeDist + this.SOFTENING_SQ);
54713
+ const fx = dx / centerDist * repMag;
54714
+ const fy = dy / centerDist * repMag;
54712
54715
  ax.set(s1.id, (ax.get(s1.id) ?? 0) - fx);
54713
54716
  ay.set(s1.id, (ay.get(s1.id) ?? 0) - fy);
54714
54717
  ax.set(s2.id, (ax.get(s2.id) ?? 0) + fx);
package/dist/cjs/index.js CHANGED
@@ -54705,10 +54705,13 @@ class ForceGraphEngine {
54705
54705
  continue;
54706
54706
  const dx = s2.cx - s1.cx;
54707
54707
  const dy = s2.cy - s1.cy;
54708
- const distSq = dx * dx + dy * dy + this.SOFTENING_SQ;
54709
- const repMag = conf.FG_REPULSION / distSq;
54710
- const fx = dx * repMag;
54711
- const fy = dy * repMag;
54708
+ const centerDist = Math.sqrt(dx * dx + dy * dy) + 0.001;
54709
+ const r1 = Math.max(s1.w, s1.h) * 0.5;
54710
+ const r2 = Math.max(s2.w, s2.h) * 0.5;
54711
+ const edgeDist = Math.max(centerDist - r1 - r2, 1);
54712
+ const repMag = conf.FG_REPULSION / (edgeDist * edgeDist + this.SOFTENING_SQ);
54713
+ const fx = dx / centerDist * repMag;
54714
+ const fy = dy / centerDist * repMag;
54712
54715
  ax.set(s1.id, (ax.get(s1.id) ?? 0) - fx);
54713
54716
  ay.set(s1.id, (ay.get(s1.id) ?? 0) - fy);
54714
54717
  ax.set(s2.id, (ax.get(s2.id) ?? 0) + fx);
package/dist/cjs/node.js CHANGED
@@ -57178,10 +57178,13 @@ class ForceGraphEngine {
57178
57178
  continue;
57179
57179
  const dx = s2.cx - s1.cx;
57180
57180
  const dy = s2.cy - s1.cy;
57181
- const distSq = dx * dx + dy * dy + this.SOFTENING_SQ;
57182
- const repMag = conf.FG_REPULSION / distSq;
57183
- const fx = dx * repMag;
57184
- const fy = dy * repMag;
57181
+ const centerDist = Math.sqrt(dx * dx + dy * dy) + 0.001;
57182
+ const r1 = Math.max(s1.w, s1.h) * 0.5;
57183
+ const r2 = Math.max(s2.w, s2.h) * 0.5;
57184
+ const edgeDist = Math.max(centerDist - r1 - r2, 1);
57185
+ const repMag = conf.FG_REPULSION / (edgeDist * edgeDist + this.SOFTENING_SQ);
57186
+ const fx = dx / centerDist * repMag;
57187
+ const fy = dy / centerDist * repMag;
57185
57188
  ax.set(s1.id, (ax.get(s1.id) ?? 0) - fx);
57186
57189
  ay.set(s1.id, (ay.get(s1.id) ?? 0) - fy);
57187
57190
  ax.set(s2.id, (ax.get(s2.id) ?? 0) + fx);
@@ -54534,10 +54534,13 @@ class ForceGraphEngine {
54534
54534
  continue;
54535
54535
  const dx = s2.cx - s1.cx;
54536
54536
  const dy = s2.cy - s1.cy;
54537
- const distSq = dx * dx + dy * dy + this.SOFTENING_SQ;
54538
- const repMag = conf.FG_REPULSION / distSq;
54539
- const fx = dx * repMag;
54540
- const fy = dy * repMag;
54537
+ const centerDist = Math.sqrt(dx * dx + dy * dy) + 0.001;
54538
+ const r1 = Math.max(s1.w, s1.h) * 0.5;
54539
+ const r2 = Math.max(s2.w, s2.h) * 0.5;
54540
+ const edgeDist = Math.max(centerDist - r1 - r2, 1);
54541
+ const repMag = conf.FG_REPULSION / (edgeDist * edgeDist + this.SOFTENING_SQ);
54542
+ const fx = dx / centerDist * repMag;
54543
+ const fy = dy / centerDist * repMag;
54541
54544
  ax.set(s1.id, (ax.get(s1.id) ?? 0) - fx);
54542
54545
  ay.set(s1.id, (ay.get(s1.id) ?? 0) - fy);
54543
54546
  ax.set(s2.id, (ax.get(s2.id) ?? 0) + fx);
package/dist/esm/index.js CHANGED
@@ -54527,10 +54527,13 @@ class ForceGraphEngine {
54527
54527
  continue;
54528
54528
  const dx = s2.cx - s1.cx;
54529
54529
  const dy = s2.cy - s1.cy;
54530
- const distSq = dx * dx + dy * dy + this.SOFTENING_SQ;
54531
- const repMag = conf.FG_REPULSION / distSq;
54532
- const fx = dx * repMag;
54533
- const fy = dy * repMag;
54530
+ const centerDist = Math.sqrt(dx * dx + dy * dy) + 0.001;
54531
+ const r1 = Math.max(s1.w, s1.h) * 0.5;
54532
+ const r2 = Math.max(s2.w, s2.h) * 0.5;
54533
+ const edgeDist = Math.max(centerDist - r1 - r2, 1);
54534
+ const repMag = conf.FG_REPULSION / (edgeDist * edgeDist + this.SOFTENING_SQ);
54535
+ const fx = dx / centerDist * repMag;
54536
+ const fy = dy / centerDist * repMag;
54534
54537
  ax.set(s1.id, (ax.get(s1.id) ?? 0) - fx);
54535
54538
  ay.set(s1.id, (ay.get(s1.id) ?? 0) - fy);
54536
54539
  ax.set(s2.id, (ax.get(s2.id) ?? 0) + fx);
package/dist/esm/node.js CHANGED
@@ -56995,10 +56995,13 @@ class ForceGraphEngine {
56995
56995
  continue;
56996
56996
  const dx = s2.cx - s1.cx;
56997
56997
  const dy = s2.cy - s1.cy;
56998
- const distSq = dx * dx + dy * dy + this.SOFTENING_SQ;
56999
- const repMag = conf.FG_REPULSION / distSq;
57000
- const fx = dx * repMag;
57001
- const fy = dy * repMag;
56998
+ const centerDist = Math.sqrt(dx * dx + dy * dy) + 0.001;
56999
+ const r1 = Math.max(s1.w, s1.h) * 0.5;
57000
+ const r2 = Math.max(s2.w, s2.h) * 0.5;
57001
+ const edgeDist = Math.max(centerDist - r1 - r2, 1);
57002
+ const repMag = conf.FG_REPULSION / (edgeDist * edgeDist + this.SOFTENING_SQ);
57003
+ const fx = dx / centerDist * repMag;
57004
+ const fy = dy / centerDist * repMag;
57002
57005
  ax.set(s1.id, (ax.get(s1.id) ?? 0) - fx);
57003
57006
  ay.set(s1.id, (ay.get(s1.id) ?? 0) - fy);
57004
57007
  ax.set(s2.id, (ax.get(s2.id) ?? 0) + fx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.13.19",
3
+ "version": "0.13.20",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",