From ada1b351fda8e1c6d2066693b830d04d61aad4e5 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 29 Mar 2024 23:53:00 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/10646 --- app/src/mobile/util/touch.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/mobile/util/touch.ts b/app/src/mobile/util/touch.ts index 2fada843d..3351393e1 100644 --- a/app/src/mobile/util/touch.ts +++ b/app/src/mobile/util/touch.ts @@ -36,7 +36,12 @@ export const handleTouchEnd = (event: TouchEvent, app: App) => { return; } const target = event.target as HTMLElement; - if (!clientX || !clientY || typeof yDiff === "undefined" || + if (!clientX) { + // 上下滚动时防止左右滚动会将 clientX 清空 + closePanel(); + return; + } + if (!clientY || typeof yDiff === "undefined" || target.tagName === "AUDIO" || hasClosestByClassName(target, "b3-dialog", true) || (window.siyuan.mobile.editor && !window.siyuan.mobile.editor.protyle.toolbar.subElement.classList.contains("fn__none")) || @@ -44,7 +49,6 @@ export const handleTouchEnd = (event: TouchEvent, app: App) => { hasClosestByClassName(target, "keyboard") || hasClosestByAttribute(target, "id", "commonMenu") ) { - closePanel(); return; } if (window.siyuan.mobile.editor) { @@ -181,9 +185,9 @@ export const handleTouchMove = (event: TouchEvent) => { xDiff = Math.floor(clientX - event.touches[0].clientX); yDiff = Math.floor(clientY - event.touches[0].clientY); + // 上下滚动防止左右滑动 if (Math.abs(xDiff) < Math.abs(yDiff)) { clientX = null; - clientY = null; return; } if (!firstDirection) {