microboard-temp 0.13.34 → 0.13.35

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.
@@ -37829,7 +37829,9 @@ class Connector2 extends BaseItem {
37829
37829
  const point5 = this.startPoint;
37830
37830
  if (point5.pointType !== "Board") {
37831
37831
  point5.recalculatePoint();
37832
- if (!this.smartJumpStartEdge()) {
37832
+ const j1 = this.smartJumpStartEdge();
37833
+ const j2 = this.smartJumpEndEdge();
37834
+ if (!j1 && !j2) {
37833
37835
  this.updatePaths();
37834
37836
  this.subject.publish(this);
37835
37837
  }
@@ -37839,7 +37841,9 @@ class Connector2 extends BaseItem {
37839
37841
  const point5 = this.endPoint;
37840
37842
  if (point5.pointType !== "Board") {
37841
37843
  point5.recalculatePoint();
37842
- if (!this.smartJumpStartEdge()) {
37844
+ const j1 = this.smartJumpEndEdge();
37845
+ const j2 = this.smartJumpStartEdge();
37846
+ if (!j1 && !j2) {
37843
37847
  this.updatePaths();
37844
37848
  this.subject.publish(this);
37845
37849
  }
@@ -37881,6 +37885,42 @@ class Connector2 extends BaseItem {
37881
37885
  this.setStartPoint(new FixedPoint(item, toRelativePoint(best, item)));
37882
37886
  return true;
37883
37887
  }
37888
+ smartJumpEndEdge() {
37889
+ const end = this.endPoint;
37890
+ if (end.pointType !== "Fixed" && end.pointType !== "Floating")
37891
+ return false;
37892
+ const item = end.item;
37893
+ const anchors = item.getSnapAnchorPoints?.();
37894
+ if (!anchors || anchors.length === 0)
37895
+ return false;
37896
+ const EPS = 2;
37897
+ const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - end.x) < EPS && Math.abs(a2.y - end.y) < EPS);
37898
+ if (!isOnAnchor)
37899
+ return false;
37900
+ const center = item.getMbr().getCenter();
37901
+ const dx = this.startPoint.x - center.x;
37902
+ const dy = this.startPoint.y - center.y;
37903
+ if (dx === 0 && dy === 0)
37904
+ return false;
37905
+ let best = anchors[0];
37906
+ let bestDot = -Infinity;
37907
+ for (const anchor of anchors) {
37908
+ const ax = anchor.x - center.x;
37909
+ const ay = anchor.y - center.y;
37910
+ const len = Math.sqrt(ax * ax + ay * ay);
37911
+ if (len === 0)
37912
+ continue;
37913
+ const dot = (ax * dx + ay * dy) / len;
37914
+ if (dot > bestDot) {
37915
+ bestDot = dot;
37916
+ best = anchor;
37917
+ }
37918
+ }
37919
+ if (Math.abs(best.x - end.x) < EPS && Math.abs(best.y - end.y) < EPS)
37920
+ return false;
37921
+ this.setEndPoint(new FixedPoint(item, toRelativePoint(best, item)));
37922
+ return true;
37923
+ }
37884
37924
  clearObservedItems() {
37885
37925
  const startPoint = this.getStartPoint();
37886
37926
  const endPoint = this.getEndPoint();
package/dist/cjs/index.js CHANGED
@@ -37829,7 +37829,9 @@ class Connector2 extends BaseItem {
37829
37829
  const point5 = this.startPoint;
37830
37830
  if (point5.pointType !== "Board") {
37831
37831
  point5.recalculatePoint();
37832
- if (!this.smartJumpStartEdge()) {
37832
+ const j1 = this.smartJumpStartEdge();
37833
+ const j2 = this.smartJumpEndEdge();
37834
+ if (!j1 && !j2) {
37833
37835
  this.updatePaths();
37834
37836
  this.subject.publish(this);
37835
37837
  }
@@ -37839,7 +37841,9 @@ class Connector2 extends BaseItem {
37839
37841
  const point5 = this.endPoint;
37840
37842
  if (point5.pointType !== "Board") {
37841
37843
  point5.recalculatePoint();
37842
- if (!this.smartJumpStartEdge()) {
37844
+ const j1 = this.smartJumpEndEdge();
37845
+ const j2 = this.smartJumpStartEdge();
37846
+ if (!j1 && !j2) {
37843
37847
  this.updatePaths();
37844
37848
  this.subject.publish(this);
37845
37849
  }
@@ -37881,6 +37885,42 @@ class Connector2 extends BaseItem {
37881
37885
  this.setStartPoint(new FixedPoint(item, toRelativePoint(best, item)));
37882
37886
  return true;
37883
37887
  }
37888
+ smartJumpEndEdge() {
37889
+ const end = this.endPoint;
37890
+ if (end.pointType !== "Fixed" && end.pointType !== "Floating")
37891
+ return false;
37892
+ const item = end.item;
37893
+ const anchors = item.getSnapAnchorPoints?.();
37894
+ if (!anchors || anchors.length === 0)
37895
+ return false;
37896
+ const EPS = 2;
37897
+ const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - end.x) < EPS && Math.abs(a2.y - end.y) < EPS);
37898
+ if (!isOnAnchor)
37899
+ return false;
37900
+ const center = item.getMbr().getCenter();
37901
+ const dx = this.startPoint.x - center.x;
37902
+ const dy = this.startPoint.y - center.y;
37903
+ if (dx === 0 && dy === 0)
37904
+ return false;
37905
+ let best = anchors[0];
37906
+ let bestDot = -Infinity;
37907
+ for (const anchor of anchors) {
37908
+ const ax = anchor.x - center.x;
37909
+ const ay = anchor.y - center.y;
37910
+ const len = Math.sqrt(ax * ax + ay * ay);
37911
+ if (len === 0)
37912
+ continue;
37913
+ const dot = (ax * dx + ay * dy) / len;
37914
+ if (dot > bestDot) {
37915
+ bestDot = dot;
37916
+ best = anchor;
37917
+ }
37918
+ }
37919
+ if (Math.abs(best.x - end.x) < EPS && Math.abs(best.y - end.y) < EPS)
37920
+ return false;
37921
+ this.setEndPoint(new FixedPoint(item, toRelativePoint(best, item)));
37922
+ return true;
37923
+ }
37884
37924
  clearObservedItems() {
37885
37925
  const startPoint = this.getStartPoint();
37886
37926
  const endPoint = this.getEndPoint();
package/dist/cjs/node.js CHANGED
@@ -40302,7 +40302,9 @@ class Connector2 extends BaseItem {
40302
40302
  const point5 = this.startPoint;
40303
40303
  if (point5.pointType !== "Board") {
40304
40304
  point5.recalculatePoint();
40305
- if (!this.smartJumpStartEdge()) {
40305
+ const j1 = this.smartJumpStartEdge();
40306
+ const j2 = this.smartJumpEndEdge();
40307
+ if (!j1 && !j2) {
40306
40308
  this.updatePaths();
40307
40309
  this.subject.publish(this);
40308
40310
  }
@@ -40312,7 +40314,9 @@ class Connector2 extends BaseItem {
40312
40314
  const point5 = this.endPoint;
40313
40315
  if (point5.pointType !== "Board") {
40314
40316
  point5.recalculatePoint();
40315
- if (!this.smartJumpStartEdge()) {
40317
+ const j1 = this.smartJumpEndEdge();
40318
+ const j2 = this.smartJumpStartEdge();
40319
+ if (!j1 && !j2) {
40316
40320
  this.updatePaths();
40317
40321
  this.subject.publish(this);
40318
40322
  }
@@ -40354,6 +40358,42 @@ class Connector2 extends BaseItem {
40354
40358
  this.setStartPoint(new FixedPoint(item, toRelativePoint(best, item)));
40355
40359
  return true;
40356
40360
  }
40361
+ smartJumpEndEdge() {
40362
+ const end = this.endPoint;
40363
+ if (end.pointType !== "Fixed" && end.pointType !== "Floating")
40364
+ return false;
40365
+ const item = end.item;
40366
+ const anchors = item.getSnapAnchorPoints?.();
40367
+ if (!anchors || anchors.length === 0)
40368
+ return false;
40369
+ const EPS = 2;
40370
+ const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - end.x) < EPS && Math.abs(a2.y - end.y) < EPS);
40371
+ if (!isOnAnchor)
40372
+ return false;
40373
+ const center = item.getMbr().getCenter();
40374
+ const dx = this.startPoint.x - center.x;
40375
+ const dy = this.startPoint.y - center.y;
40376
+ if (dx === 0 && dy === 0)
40377
+ return false;
40378
+ let best = anchors[0];
40379
+ let bestDot = -Infinity;
40380
+ for (const anchor of anchors) {
40381
+ const ax = anchor.x - center.x;
40382
+ const ay = anchor.y - center.y;
40383
+ const len = Math.sqrt(ax * ax + ay * ay);
40384
+ if (len === 0)
40385
+ continue;
40386
+ const dot = (ax * dx + ay * dy) / len;
40387
+ if (dot > bestDot) {
40388
+ bestDot = dot;
40389
+ best = anchor;
40390
+ }
40391
+ }
40392
+ if (Math.abs(best.x - end.x) < EPS && Math.abs(best.y - end.y) < EPS)
40393
+ return false;
40394
+ this.setEndPoint(new FixedPoint(item, toRelativePoint(best, item)));
40395
+ return true;
40396
+ }
40357
40397
  clearObservedItems() {
40358
40398
  const startPoint = this.getStartPoint();
40359
40399
  const endPoint = this.getEndPoint();
@@ -37658,7 +37658,9 @@ class Connector2 extends BaseItem {
37658
37658
  const point5 = this.startPoint;
37659
37659
  if (point5.pointType !== "Board") {
37660
37660
  point5.recalculatePoint();
37661
- if (!this.smartJumpStartEdge()) {
37661
+ const j1 = this.smartJumpStartEdge();
37662
+ const j2 = this.smartJumpEndEdge();
37663
+ if (!j1 && !j2) {
37662
37664
  this.updatePaths();
37663
37665
  this.subject.publish(this);
37664
37666
  }
@@ -37668,7 +37670,9 @@ class Connector2 extends BaseItem {
37668
37670
  const point5 = this.endPoint;
37669
37671
  if (point5.pointType !== "Board") {
37670
37672
  point5.recalculatePoint();
37671
- if (!this.smartJumpStartEdge()) {
37673
+ const j1 = this.smartJumpEndEdge();
37674
+ const j2 = this.smartJumpStartEdge();
37675
+ if (!j1 && !j2) {
37672
37676
  this.updatePaths();
37673
37677
  this.subject.publish(this);
37674
37678
  }
@@ -37710,6 +37714,42 @@ class Connector2 extends BaseItem {
37710
37714
  this.setStartPoint(new FixedPoint(item, toRelativePoint(best, item)));
37711
37715
  return true;
37712
37716
  }
37717
+ smartJumpEndEdge() {
37718
+ const end = this.endPoint;
37719
+ if (end.pointType !== "Fixed" && end.pointType !== "Floating")
37720
+ return false;
37721
+ const item = end.item;
37722
+ const anchors = item.getSnapAnchorPoints?.();
37723
+ if (!anchors || anchors.length === 0)
37724
+ return false;
37725
+ const EPS = 2;
37726
+ const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - end.x) < EPS && Math.abs(a2.y - end.y) < EPS);
37727
+ if (!isOnAnchor)
37728
+ return false;
37729
+ const center = item.getMbr().getCenter();
37730
+ const dx = this.startPoint.x - center.x;
37731
+ const dy = this.startPoint.y - center.y;
37732
+ if (dx === 0 && dy === 0)
37733
+ return false;
37734
+ let best = anchors[0];
37735
+ let bestDot = -Infinity;
37736
+ for (const anchor of anchors) {
37737
+ const ax = anchor.x - center.x;
37738
+ const ay = anchor.y - center.y;
37739
+ const len = Math.sqrt(ax * ax + ay * ay);
37740
+ if (len === 0)
37741
+ continue;
37742
+ const dot = (ax * dx + ay * dy) / len;
37743
+ if (dot > bestDot) {
37744
+ bestDot = dot;
37745
+ best = anchor;
37746
+ }
37747
+ }
37748
+ if (Math.abs(best.x - end.x) < EPS && Math.abs(best.y - end.y) < EPS)
37749
+ return false;
37750
+ this.setEndPoint(new FixedPoint(item, toRelativePoint(best, item)));
37751
+ return true;
37752
+ }
37713
37753
  clearObservedItems() {
37714
37754
  const startPoint = this.getStartPoint();
37715
37755
  const endPoint = this.getEndPoint();
package/dist/esm/index.js CHANGED
@@ -37651,7 +37651,9 @@ class Connector2 extends BaseItem {
37651
37651
  const point5 = this.startPoint;
37652
37652
  if (point5.pointType !== "Board") {
37653
37653
  point5.recalculatePoint();
37654
- if (!this.smartJumpStartEdge()) {
37654
+ const j1 = this.smartJumpStartEdge();
37655
+ const j2 = this.smartJumpEndEdge();
37656
+ if (!j1 && !j2) {
37655
37657
  this.updatePaths();
37656
37658
  this.subject.publish(this);
37657
37659
  }
@@ -37661,7 +37663,9 @@ class Connector2 extends BaseItem {
37661
37663
  const point5 = this.endPoint;
37662
37664
  if (point5.pointType !== "Board") {
37663
37665
  point5.recalculatePoint();
37664
- if (!this.smartJumpStartEdge()) {
37666
+ const j1 = this.smartJumpEndEdge();
37667
+ const j2 = this.smartJumpStartEdge();
37668
+ if (!j1 && !j2) {
37665
37669
  this.updatePaths();
37666
37670
  this.subject.publish(this);
37667
37671
  }
@@ -37703,6 +37707,42 @@ class Connector2 extends BaseItem {
37703
37707
  this.setStartPoint(new FixedPoint(item, toRelativePoint(best, item)));
37704
37708
  return true;
37705
37709
  }
37710
+ smartJumpEndEdge() {
37711
+ const end = this.endPoint;
37712
+ if (end.pointType !== "Fixed" && end.pointType !== "Floating")
37713
+ return false;
37714
+ const item = end.item;
37715
+ const anchors = item.getSnapAnchorPoints?.();
37716
+ if (!anchors || anchors.length === 0)
37717
+ return false;
37718
+ const EPS = 2;
37719
+ const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - end.x) < EPS && Math.abs(a2.y - end.y) < EPS);
37720
+ if (!isOnAnchor)
37721
+ return false;
37722
+ const center = item.getMbr().getCenter();
37723
+ const dx = this.startPoint.x - center.x;
37724
+ const dy = this.startPoint.y - center.y;
37725
+ if (dx === 0 && dy === 0)
37726
+ return false;
37727
+ let best = anchors[0];
37728
+ let bestDot = -Infinity;
37729
+ for (const anchor of anchors) {
37730
+ const ax = anchor.x - center.x;
37731
+ const ay = anchor.y - center.y;
37732
+ const len = Math.sqrt(ax * ax + ay * ay);
37733
+ if (len === 0)
37734
+ continue;
37735
+ const dot = (ax * dx + ay * dy) / len;
37736
+ if (dot > bestDot) {
37737
+ bestDot = dot;
37738
+ best = anchor;
37739
+ }
37740
+ }
37741
+ if (Math.abs(best.x - end.x) < EPS && Math.abs(best.y - end.y) < EPS)
37742
+ return false;
37743
+ this.setEndPoint(new FixedPoint(item, toRelativePoint(best, item)));
37744
+ return true;
37745
+ }
37706
37746
  clearObservedItems() {
37707
37747
  const startPoint = this.getStartPoint();
37708
37748
  const endPoint = this.getEndPoint();
package/dist/esm/node.js CHANGED
@@ -40119,7 +40119,9 @@ class Connector2 extends BaseItem {
40119
40119
  const point5 = this.startPoint;
40120
40120
  if (point5.pointType !== "Board") {
40121
40121
  point5.recalculatePoint();
40122
- if (!this.smartJumpStartEdge()) {
40122
+ const j1 = this.smartJumpStartEdge();
40123
+ const j2 = this.smartJumpEndEdge();
40124
+ if (!j1 && !j2) {
40123
40125
  this.updatePaths();
40124
40126
  this.subject.publish(this);
40125
40127
  }
@@ -40129,7 +40131,9 @@ class Connector2 extends BaseItem {
40129
40131
  const point5 = this.endPoint;
40130
40132
  if (point5.pointType !== "Board") {
40131
40133
  point5.recalculatePoint();
40132
- if (!this.smartJumpStartEdge()) {
40134
+ const j1 = this.smartJumpEndEdge();
40135
+ const j2 = this.smartJumpStartEdge();
40136
+ if (!j1 && !j2) {
40133
40137
  this.updatePaths();
40134
40138
  this.subject.publish(this);
40135
40139
  }
@@ -40171,6 +40175,42 @@ class Connector2 extends BaseItem {
40171
40175
  this.setStartPoint(new FixedPoint(item, toRelativePoint(best, item)));
40172
40176
  return true;
40173
40177
  }
40178
+ smartJumpEndEdge() {
40179
+ const end = this.endPoint;
40180
+ if (end.pointType !== "Fixed" && end.pointType !== "Floating")
40181
+ return false;
40182
+ const item = end.item;
40183
+ const anchors = item.getSnapAnchorPoints?.();
40184
+ if (!anchors || anchors.length === 0)
40185
+ return false;
40186
+ const EPS = 2;
40187
+ const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - end.x) < EPS && Math.abs(a2.y - end.y) < EPS);
40188
+ if (!isOnAnchor)
40189
+ return false;
40190
+ const center = item.getMbr().getCenter();
40191
+ const dx = this.startPoint.x - center.x;
40192
+ const dy = this.startPoint.y - center.y;
40193
+ if (dx === 0 && dy === 0)
40194
+ return false;
40195
+ let best = anchors[0];
40196
+ let bestDot = -Infinity;
40197
+ for (const anchor of anchors) {
40198
+ const ax = anchor.x - center.x;
40199
+ const ay = anchor.y - center.y;
40200
+ const len = Math.sqrt(ax * ax + ay * ay);
40201
+ if (len === 0)
40202
+ continue;
40203
+ const dot = (ax * dx + ay * dy) / len;
40204
+ if (dot > bestDot) {
40205
+ bestDot = dot;
40206
+ best = anchor;
40207
+ }
40208
+ }
40209
+ if (Math.abs(best.x - end.x) < EPS && Math.abs(best.y - end.y) < EPS)
40210
+ return false;
40211
+ this.setEndPoint(new FixedPoint(item, toRelativePoint(best, item)));
40212
+ return true;
40213
+ }
40174
40214
  clearObservedItems() {
40175
40215
  const startPoint = this.getStartPoint();
40176
40216
  const endPoint = this.getEndPoint();
@@ -64,6 +64,8 @@ export declare class Connector extends BaseItem {
64
64
  * Returns true if a jump was performed (caller should skip its own updatePaths/publish).
65
65
  */
66
66
  private smartJumpStartEdge;
67
+ /** Mirror of smartJumpStartEdge for the end point. */
68
+ private smartJumpEndEdge;
67
69
  clearObservedItems(): void;
68
70
  private unsubscribeFromItem;
69
71
  private subscribeToItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.13.34",
3
+ "version": "0.13.35",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",