From 76e7ecb19c09b5abb067c07ae50f5eea1ebba0bb Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 4 May 2026 12:53:14 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/13436 --- app/src/boot/globalEvent/touch.ts | 29 ---------------------------- app/src/protyle/header/Background.ts | 9 ++++----- app/src/util/touchDragBridge.ts | 4 +++- 3 files changed, 7 insertions(+), 35 deletions(-) diff --git a/app/src/boot/globalEvent/touch.ts b/app/src/boot/globalEvent/touch.ts index b00b96bd1..a6ddf6088 100644 --- a/app/src/boot/globalEvent/touch.ts +++ b/app/src/boot/globalEvent/touch.ts @@ -18,37 +18,8 @@ import {Editor} from "../../editor"; import {hideTooltip} from "../../dialog/tooltip"; export const globalTouchStart = (event: TouchEvent) => { - // 文档背景位置调整 const target = event.target as HTMLElement; const backgroundElement = hasClosestByClassName(target, "protyle-background"); - if (backgroundElement && target.tagName === "IMG" && backgroundElement.firstElementChild.querySelector(".protyle-icons").classList.contains("fn__none")) { - const contentElement = hasClosestByClassName(target, "protyle-content", true); - if (!contentElement) { - return false; - } - contentElement.style.overflow = "hidden"; - const y = event.touches[0].clientY; - const height = (target as HTMLImageElement).naturalHeight * target.clientWidth / (target as HTMLImageElement).naturalWidth - target.clientHeight; - let originalPositionY = parseFloat(target.style.objectPosition.substring(7)) || 50; - if (target.style.objectPosition.endsWith("px")) { - originalPositionY = -parseInt(target.style.objectPosition.substring(7)) / height * 100; - } - - const documentSelf = document; - documentSelf.ontouchmove = (moveEvent) => { - target.style.objectPosition = `center ${((y - moveEvent.touches[0].clientY) / height * 100 + originalPositionY).toFixed(2)}%`; - }; - documentSelf.ontouchend = () => { - contentElement.style.overflow = ""; - documentSelf.ontouchmove = null; - documentSelf.ontouchstart = null; - documentSelf.ondragstart = null; - documentSelf.onselectstart = null; - documentSelf.onselect = null; - }; - event.stopImmediatePropagation(); - return true; - } if (backgroundElement) { if (backgroundElement.classList.contains("protyle-background--enable")) { backgroundElement.classList.add("protyle-background--mobileshow"); diff --git a/app/src/protyle/header/Background.ts b/app/src/protyle/header/Background.ts index cbff2bef4..2b2b54c19 100644 --- a/app/src/protyle/header/Background.ts +++ b/app/src/protyle/header/Background.ts @@ -512,8 +512,8 @@ export class Background { }; const onMouseUp = (upEvent: MouseEvent) => { - window.removeEventListener("mousemove", onMouseMove); - window.removeEventListener("mouseup", onMouseUp, true); + document.onmousemove = null; + document.onmouseup = null; document.body.style.cursor = ""; if (isDragging) { @@ -544,9 +544,8 @@ export class Background { } }; - // 使用捕获阶段监听 mouseup,确保能第一时间拦截拖拽后的 click - window.addEventListener("mousemove", onMouseMove); - window.addEventListener("mouseup", onMouseUp, true); + document.onmousemove = (e) => onMouseMove(e as MouseEvent); + document.onmouseup = (e) => onMouseUp(e as MouseEvent); }); } diff --git a/app/src/util/touchDragBridge.ts b/app/src/util/touchDragBridge.ts index 657778c61..840541254 100644 --- a/app/src/util/touchDragBridge.ts +++ b/app/src/util/touchDragBridge.ts @@ -76,7 +76,9 @@ const handleManualTouchStart = (e: TouchEvent) => { !target.closest(".av__widthdrag") && !target.closest(".av__drag-fill") && !target.closest(".protyle-action__drag") && - !target.closest(".table__resize")) return; + !target.closest(".table__resize") && + !target.closest(".protyle-background__img") && + !target.closest(".b3-chip")) return; const touch = e.touches[0]; dispatchSyntheticMouse("mousedown", touch.clientX, touch.clientY, target);