From 4cf03e9f8a40ff25b6fb0669c3a786aa93ecec58 Mon Sep 17 00:00:00 2001 From: Jeffrey Chen <78434827+TCOTC@users.noreply.github.com> Date: Mon, 3 Feb 2025 17:19:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=BC=A0=E6=A0=87=E5=9C=A8=20.protyle-s?= =?UTF-8?q?croll=20=E4=B8=8A=E6=97=A0=E6=B3=95=E6=BB=9A=E5=8A=A8=E6=96=87?= =?UTF-8?q?=E6=A1=A3=20(#14006)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 鼠标在 .protyle-scroll 上无法滚动文档 * fix: 鼠标在 .protyle-scroll 上无法滚动文档 --- app/src/protyle/scroll/index.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/src/protyle/scroll/index.ts b/app/src/protyle/scroll/index.ts index b9d8b614d..99ab6c0cf 100644 --- a/app/src/protyle/scroll/index.ts +++ b/app/src/protyle/scroll/index.ts @@ -55,6 +55,30 @@ export class Scroll { this.setIndex(protyle); } }); + this.parentElement.addEventListener("mousewheel", (event: WheelEvent) => { + if (protyle.contentElement.scrollTop + event.deltaY < protyle.contentElement.clientHeight) { + // 禁用滚动时会产生抖动 https://ld246.com/article/1666717094418 + protyle.contentElement.style.width = (protyle.contentElement.offsetWidth) + "px"; + protyle.contentElement.style.overflow = "hidden"; + protyle.wysiwyg.element.setAttribute("data-top", protyle.contentElement.scrollTop.toString()); + fetchPost("/api/filetree/getDoc", { + id: protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-id"), + mode: 1, + size: window.siyuan.config.editor.dynamicLoadBlocks, + }, getResponse => { + protyle.contentElement.style.overflow = ""; + protyle.contentElement.style.width = ""; + onGet({ + data: getResponse, + protyle, + action: [Constants.CB_GET_BEFORE, Constants.CB_GET_UNCHANGEID], + }); + protyle.contentElement.scrollTop += event.deltaY; + }); + return; + } + protyle.contentElement.scrollTop += event.deltaY; + }, {passive: true}); } private setIndex(protyle: IProtyle) {