From b7be82bd41e48ed854ad2d9a1aac0926ee69533c Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Fri, 10 Jul 2026 20:13:59 +0900 Subject: [PATCH] fix --- .../src/components/MkImageGallery.item.vue | 23 +++++++++++++++++++ packages/frontend/src/utility/double-tap.ts | 6 +++++ 2 files changed, 29 insertions(+) diff --git a/packages/frontend/src/components/MkImageGallery.item.vue b/packages/frontend/src/components/MkImageGallery.item.vue index 6c46d44c8e..2e6637ddc4 100644 --- a/packages/frontend/src/components/MkImageGallery.item.vue +++ b/packages/frontend/src/components/MkImageGallery.item.vue @@ -10,8 +10,11 @@ SPDX-License-Identifier: AGPL-3.0-only @pointerdown.passive="onPointerdown" @pointermove.passive="onPointermove" @pointerup.passive="onPointerup" + @pointercancel.passive="cancelPointerGesture" @touchstart.passive="onTouchstart" @touchmove.passive="onTouchmove" + @touchcancel.passive="cancelPointerGesture" + @contextmenu="cancelPointerGesture" @wheel="onWheel" @click="onCLick" > @@ -383,6 +386,26 @@ const doubleTapDetector = makeDoubleTapDetector((ev) => { } }); +function cancelPointerGesture() { + const wasVerticalSwiping = isVerticalSwiping; + const wasHorizontalSwiping = isHorizontalSwiping; + + pointerEventCache.clear(); + prevTwoTouchPointsDistance = 0; + currentPointerId = null; + isDragging = false; + isClick = false; + pointerVec = { x: 0, y: 0 }; + verticalSwipeDelta = 0; + horizontalSwipeDelta = 0; + isVerticalSwiping = false; + isHorizontalSwiping = false; + doubleTapDetector.reset(); + + if (wasVerticalSwiping) resetToNeutral(); + if (wasHorizontalSwiping) emit('cancelHorizontalSwipe'); +} + function onTouchstart(ev: TouchEvent) { ev.preventDefault(); ev.stopPropagation(); diff --git a/packages/frontend/src/utility/double-tap.ts b/packages/frontend/src/utility/double-tap.ts index 88b79e4217..a5242dc508 100644 --- a/packages/frontend/src/utility/double-tap.ts +++ b/packages/frontend/src/utility/double-tap.ts @@ -43,8 +43,14 @@ export function makeDoubleTapDetector(onDoubletap: (event: TouchEvent) => void) } } + function reset() { + lastTapTime = 0; + lastTapPosition = { x: 0, y: 0 }; + } + return { onTouchstart, onTouchmove, + reset, }; }