feat(nds): dispatch mousedown and mouseup even on touch start and end

This commit is contained in:
2026-02-13 00:35:16 +01:00
parent 515c630a60
commit d99410472e

View File

@@ -96,14 +96,29 @@ const dispatchSwipe = (endX: number, endY: number) => {
const handleTouchStart = (event: TouchEvent) => {
const touch = event.touches[0];
if (!touch) return;
swipeStartX = touch.clientX;
swipeStartY = touch.clientY;
canvas.value?.dispatchEvent(
new MouseEvent("mousedown", {
clientX: touch.clientX,
clientY: touch.clientY,
}),
);
};
const handleTouchEnd = (event: TouchEvent) => {
const touch = event.changedTouches[0];
if (!touch) return;
dispatchSwipe(touch.clientX, touch.clientY);
document.dispatchEvent(
new MouseEvent("mouseup", {
clientX: touch.clientX,
clientY: touch.clientY,
}),
);
};
let mouseSwiping = false;