fix: 鼠标在 .protyle-scroll 上无法滚动文档 (#14006)

* fix: 鼠标在 .protyle-scroll 上无法滚动文档

* fix: 鼠标在 .protyle-scroll 上无法滚动文档
This commit is contained in:
Jeffrey Chen 2025-02-03 17:19:12 +08:00 committed by GitHub
parent d85fc1fd32
commit 4cf03e9f8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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) {