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 handleTouchStart = (event: TouchEvent) => {
|
||||||
const touch = event.touches[0];
|
const touch = event.touches[0];
|
||||||
if (!touch) return;
|
if (!touch) return;
|
||||||
|
|
||||||
swipeStartX = touch.clientX;
|
swipeStartX = touch.clientX;
|
||||||
swipeStartY = touch.clientY;
|
swipeStartY = touch.clientY;
|
||||||
|
|
||||||
|
canvas.value?.dispatchEvent(
|
||||||
|
new MouseEvent("mousedown", {
|
||||||
|
clientX: touch.clientX,
|
||||||
|
clientY: touch.clientY,
|
||||||
|
}),
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTouchEnd = (event: TouchEvent) => {
|
const handleTouchEnd = (event: TouchEvent) => {
|
||||||
const touch = event.changedTouches[0];
|
const touch = event.changedTouches[0];
|
||||||
if (!touch) return;
|
if (!touch) return;
|
||||||
|
|
||||||
dispatchSwipe(touch.clientX, touch.clientY);
|
dispatchSwipe(touch.clientX, touch.clientY);
|
||||||
|
document.dispatchEvent(
|
||||||
|
new MouseEvent("mouseup", {
|
||||||
|
clientX: touch.clientX,
|
||||||
|
clientY: touch.clientY,
|
||||||
|
}),
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
let mouseSwiping = false;
|
let mouseSwiping = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user