@sendbird/actionbook-core 0.10.16 → 0.10.17
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.
- package/dist/ui/index.js +40 -15
- package/dist/ui/index.js.map +1 -1
- package/package.json +1 -1
package/dist/ui/index.js
CHANGED
|
@@ -7696,10 +7696,15 @@ var DragHandleController = class {
|
|
|
7696
7696
|
this.activeMenuCleanup = null;
|
|
7697
7697
|
}
|
|
7698
7698
|
}
|
|
7699
|
-
|
|
7699
|
+
/** Show the context menu at a fixed screen position (pointer coordinates). */
|
|
7700
|
+
showMenuAt(blockIndex, x, y) {
|
|
7700
7701
|
this.dismissMenu();
|
|
7701
7702
|
const menu = document.createElement("div");
|
|
7702
7703
|
menu.className = "ab-dh-menu";
|
|
7704
|
+
menu.style.position = "fixed";
|
|
7705
|
+
menu.style.left = `${x}px`;
|
|
7706
|
+
menu.style.top = `${y + 4}px`;
|
|
7707
|
+
menu.style.zIndex = "9999";
|
|
7703
7708
|
const deleteBtn = document.createElement("button");
|
|
7704
7709
|
deleteBtn.className = "ab-dh-menu-item";
|
|
7705
7710
|
deleteBtn.textContent = "Delete";
|
|
@@ -7710,7 +7715,7 @@ var DragHandleController = class {
|
|
|
7710
7715
|
this.dismissMenu();
|
|
7711
7716
|
});
|
|
7712
7717
|
menu.appendChild(deleteBtn);
|
|
7713
|
-
|
|
7718
|
+
document.body.appendChild(menu);
|
|
7714
7719
|
this.activeMenu = menu;
|
|
7715
7720
|
const onOutside = (e) => {
|
|
7716
7721
|
if (!menu.contains(e.target)) {
|
|
@@ -7735,36 +7740,56 @@ var DragHandleController = class {
|
|
|
7735
7740
|
let currentIndex = index;
|
|
7736
7741
|
let downX = 0;
|
|
7737
7742
|
let downY = 0;
|
|
7738
|
-
let
|
|
7743
|
+
let dragStarted = false;
|
|
7744
|
+
let pointerId = -1;
|
|
7739
7745
|
let menuWasOpen = false;
|
|
7746
|
+
const DRAG_THRESHOLD2 = 4;
|
|
7740
7747
|
const onPointerDown = (e) => {
|
|
7741
7748
|
if (this.activeMenu && this.activeMenu.contains(e.target)) return;
|
|
7742
7749
|
e.preventDefault();
|
|
7750
|
+
e.stopPropagation();
|
|
7743
7751
|
if (!this.view.editable) return;
|
|
7744
7752
|
menuWasOpen = !!this.activeMenu;
|
|
7745
7753
|
this.dismissMenu();
|
|
7746
7754
|
downX = e.clientX;
|
|
7747
7755
|
downY = e.clientY;
|
|
7748
|
-
|
|
7756
|
+
dragStarted = false;
|
|
7757
|
+
pointerId = e.pointerId;
|
|
7749
7758
|
el.setPointerCapture(e.pointerId);
|
|
7750
|
-
this.prevBlocks = this.collectBlocks();
|
|
7751
|
-
this.syncHandlePositions();
|
|
7752
|
-
this.startDrag(currentIndex, el, e);
|
|
7753
7759
|
};
|
|
7754
7760
|
const onPointerMove = (e) => {
|
|
7755
|
-
if (
|
|
7756
|
-
|
|
7761
|
+
if (e.pointerId !== pointerId) return;
|
|
7762
|
+
const dx = Math.abs(e.clientX - downX);
|
|
7763
|
+
const dy = Math.abs(e.clientY - downY);
|
|
7764
|
+
if (!dragStarted && (dx > DRAG_THRESHOLD2 || dy > DRAG_THRESHOLD2)) {
|
|
7765
|
+
dragStarted = true;
|
|
7766
|
+
this.prevBlocks = this.collectBlocks();
|
|
7767
|
+
this.syncHandlePositions();
|
|
7768
|
+
this.startDrag(currentIndex, el, e);
|
|
7769
|
+
}
|
|
7770
|
+
if (dragStarted) {
|
|
7771
|
+
this.onPointerMove(e);
|
|
7757
7772
|
}
|
|
7758
|
-
this.onPointerMove(e);
|
|
7759
7773
|
};
|
|
7760
7774
|
const onPointerUp = (e) => {
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7775
|
+
if (e.pointerId !== pointerId) return;
|
|
7776
|
+
e.preventDefault();
|
|
7777
|
+
e.stopPropagation();
|
|
7778
|
+
if (dragStarted) {
|
|
7779
|
+
this.onPointerUp(e);
|
|
7780
|
+
} else if (!menuWasOpen) {
|
|
7781
|
+
this.showMenuAt(currentIndex, downX, downY);
|
|
7764
7782
|
}
|
|
7783
|
+
pointerId = -1;
|
|
7784
|
+
};
|
|
7785
|
+
const onLostCapture = () => {
|
|
7786
|
+
if (dragStarted) this.cancelDrag();
|
|
7787
|
+
pointerId = -1;
|
|
7788
|
+
};
|
|
7789
|
+
const onPointerCancel = () => {
|
|
7790
|
+
if (dragStarted) this.cancelDrag();
|
|
7791
|
+
pointerId = -1;
|
|
7765
7792
|
};
|
|
7766
|
-
const onLostCapture = () => this.cancelDrag();
|
|
7767
|
-
const onPointerCancel = () => this.cancelDrag();
|
|
7768
7793
|
el.addEventListener("pointerdown", onPointerDown);
|
|
7769
7794
|
el.addEventListener("pointermove", onPointerMove);
|
|
7770
7795
|
el.addEventListener("pointerup", onPointerUp);
|