@xpert-ai/chatkit-web-component 0.5.1 → 0.5.3
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.
|
@@ -1431,6 +1431,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1431
1431
|
this.lastDragPosition = null;
|
|
1432
1432
|
this.lastDragClientX = null;
|
|
1433
1433
|
this.dragAnimation = null;
|
|
1434
|
+
this.activePointerId = null;
|
|
1434
1435
|
this.isDragging = false;
|
|
1435
1436
|
this.isHovering = false;
|
|
1436
1437
|
this.movedDuringDrag = false;
|
|
@@ -1562,7 +1563,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1562
1563
|
};
|
|
1563
1564
|
this.handlePointerDown = (event) => {
|
|
1564
1565
|
var _a2, _b2;
|
|
1565
|
-
if (event.button !== 0 || event.ctrlKey) {
|
|
1566
|
+
if (event.button !== 0 || event.ctrlKey || this.isDragging) {
|
|
1566
1567
|
return;
|
|
1567
1568
|
}
|
|
1568
1569
|
this.closeContextMenu();
|
|
@@ -1588,12 +1589,17 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1588
1589
|
this.movedDuringDrag = false;
|
|
1589
1590
|
this.dragPosition = nextPosition;
|
|
1590
1591
|
this.isDragging = true;
|
|
1592
|
+
this.activePointerId = event.pointerId;
|
|
1591
1593
|
this.clearRestingDelayTimer();
|
|
1592
1594
|
this.isHovering = true;
|
|
1595
|
+
this.captureActivePointer();
|
|
1593
1596
|
this.installDragListeners();
|
|
1594
1597
|
this.rescheduleAnimation();
|
|
1595
1598
|
};
|
|
1596
1599
|
this.handlePointerMove = (event) => {
|
|
1600
|
+
if (!this.isActiveDragPointer(event)) {
|
|
1601
|
+
return;
|
|
1602
|
+
}
|
|
1597
1603
|
const nextPosition = this.getNextDragPosition(event);
|
|
1598
1604
|
const last = this.lastDragPosition;
|
|
1599
1605
|
if (last && (Math.abs(last.x - nextPosition.x) > DRAG_DIRECTION_THRESHOLD_PX || Math.abs(last.y - nextPosition.y) > DRAG_DIRECTION_THRESHOLD_PX)) {
|
|
@@ -1613,20 +1619,18 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1613
1619
|
this.render();
|
|
1614
1620
|
};
|
|
1615
1621
|
this.handlePointerUp = (event) => {
|
|
1622
|
+
if (!this.isActiveDragPointer(event)) {
|
|
1623
|
+
return;
|
|
1624
|
+
}
|
|
1616
1625
|
const finalPosition = this.lastDragPosition ?? this.getNextDragPosition(event);
|
|
1617
|
-
this.
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
this.
|
|
1621
|
-
|
|
1622
|
-
this.persistPosition(finalPosition);
|
|
1623
|
-
if (event.pointerType === "mouse" && this.isPointerOverPet(event)) {
|
|
1624
|
-
this.isHovering = true;
|
|
1625
|
-
this.rescheduleAnimation();
|
|
1626
|
-
} else {
|
|
1627
|
-
this.enterRestingAfterDelay();
|
|
1628
|
-
this.rescheduleAnimation();
|
|
1626
|
+
this.finishDrag(finalPosition, event);
|
|
1627
|
+
};
|
|
1628
|
+
this.handleLostPointerCapture = (event) => {
|
|
1629
|
+
if (!this.isActiveDragPointer(event)) {
|
|
1630
|
+
return;
|
|
1629
1631
|
}
|
|
1632
|
+
const finalPosition = this.lastDragPosition ?? this.getNextDragPosition(event);
|
|
1633
|
+
this.finishDrag(finalPosition, event);
|
|
1630
1634
|
};
|
|
1631
1635
|
this.handleClick = () => {
|
|
1632
1636
|
var _a2;
|
|
@@ -1830,6 +1834,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1830
1834
|
pet.addEventListener("pointerenter", this.handlePointerEnter);
|
|
1831
1835
|
pet.addEventListener("pointerleave", this.handlePointerLeave);
|
|
1832
1836
|
pet.addEventListener("pointerdown", this.handlePointerDown);
|
|
1837
|
+
pet.addEventListener("lostpointercapture", this.handleLostPointerCapture);
|
|
1833
1838
|
pet.addEventListener("contextmenu", this.handleContextMenu);
|
|
1834
1839
|
pet.addEventListener("click", this.handleClick);
|
|
1835
1840
|
overlay.append(style, pet);
|
|
@@ -1839,6 +1844,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1839
1844
|
}
|
|
1840
1845
|
removeOverlay() {
|
|
1841
1846
|
var _a2;
|
|
1847
|
+
this.cancelActiveDrag();
|
|
1842
1848
|
this.clearRestingDelayTimer();
|
|
1843
1849
|
this.clearTimers();
|
|
1844
1850
|
this.closeContextMenu();
|
|
@@ -1855,6 +1861,10 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1855
1861
|
"pointerdown",
|
|
1856
1862
|
this.handlePointerDown
|
|
1857
1863
|
);
|
|
1864
|
+
this.petElement.removeEventListener(
|
|
1865
|
+
"lostpointercapture",
|
|
1866
|
+
this.handleLostPointerCapture
|
|
1867
|
+
);
|
|
1858
1868
|
this.petElement.removeEventListener(
|
|
1859
1869
|
"contextmenu",
|
|
1860
1870
|
this.handleContextMenu
|
|
@@ -2572,6 +2582,34 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2572
2582
|
this.render();
|
|
2573
2583
|
}
|
|
2574
2584
|
}
|
|
2585
|
+
captureActivePointer() {
|
|
2586
|
+
const pointerId = this.activePointerId;
|
|
2587
|
+
const pet = this.petElement;
|
|
2588
|
+
if (pointerId === null || typeof (pet == null ? void 0 : pet.setPointerCapture) !== "function") {
|
|
2589
|
+
return;
|
|
2590
|
+
}
|
|
2591
|
+
try {
|
|
2592
|
+
pet.setPointerCapture(pointerId);
|
|
2593
|
+
} catch {
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
releaseActivePointer() {
|
|
2597
|
+
const pointerId = this.activePointerId;
|
|
2598
|
+
const pet = this.petElement;
|
|
2599
|
+
this.activePointerId = null;
|
|
2600
|
+
if (pointerId === null || typeof (pet == null ? void 0 : pet.hasPointerCapture) !== "function" || typeof pet.releasePointerCapture !== "function") {
|
|
2601
|
+
return;
|
|
2602
|
+
}
|
|
2603
|
+
try {
|
|
2604
|
+
if (pet.hasPointerCapture(pointerId)) {
|
|
2605
|
+
pet.releasePointerCapture(pointerId);
|
|
2606
|
+
}
|
|
2607
|
+
} catch {
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
isActiveDragPointer(event) {
|
|
2611
|
+
return this.isDragging && event.pointerId === this.activePointerId;
|
|
2612
|
+
}
|
|
2575
2613
|
getNextDragPosition(event) {
|
|
2576
2614
|
if (!this.options) {
|
|
2577
2615
|
return { x: 0, y: 0 };
|
|
@@ -2586,12 +2624,35 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2586
2624
|
normalizeBoundsPadding(this.options.position.boundsPadding)
|
|
2587
2625
|
);
|
|
2588
2626
|
}
|
|
2627
|
+
finishDrag(finalPosition, event) {
|
|
2628
|
+
this.isDragging = false;
|
|
2629
|
+
this.dragPosition = null;
|
|
2630
|
+
this.dragAnimation = null;
|
|
2631
|
+
this.lastDragClientX = null;
|
|
2632
|
+
this.removeDragListeners();
|
|
2633
|
+
this.releaseActivePointer();
|
|
2634
|
+
this.persistPosition(finalPosition);
|
|
2635
|
+
if (event.pointerType === "mouse" && this.isPointerOverPet(event)) {
|
|
2636
|
+
this.isHovering = true;
|
|
2637
|
+
this.rescheduleAnimation();
|
|
2638
|
+
} else {
|
|
2639
|
+
this.enterRestingAfterDelay();
|
|
2640
|
+
this.rescheduleAnimation();
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
cancelActiveDrag() {
|
|
2644
|
+
this.isDragging = false;
|
|
2645
|
+
this.dragPosition = null;
|
|
2646
|
+
this.dragAnimation = null;
|
|
2647
|
+
this.lastDragPosition = null;
|
|
2648
|
+
this.lastDragClientX = null;
|
|
2649
|
+
this.removeDragListeners();
|
|
2650
|
+
this.releaseActivePointer();
|
|
2651
|
+
}
|
|
2589
2652
|
installDragListeners() {
|
|
2590
2653
|
window.addEventListener("pointermove", this.handlePointerMove);
|
|
2591
|
-
window.addEventListener("pointerup", this.handlePointerUp
|
|
2592
|
-
window.addEventListener("pointercancel", this.handlePointerUp
|
|
2593
|
-
once: true
|
|
2594
|
-
});
|
|
2654
|
+
window.addEventListener("pointerup", this.handlePointerUp);
|
|
2655
|
+
window.addEventListener("pointercancel", this.handlePointerUp);
|
|
2595
2656
|
}
|
|
2596
2657
|
removeDragListeners() {
|
|
2597
2658
|
window.removeEventListener("pointermove", this.handlePointerMove);
|