feat(nds): dispatch mousedown and mouseup even on touch start and end
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user