From a1e6a861347214c41cb4df77f35c5313d77f6628 Mon Sep 17 00:00:00 2001 From: xiaoqidun Date: Thu, 9 Jul 2026 19:06:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=89=8D=E7=AB=AF=E7=95=8C=E9=9D=A2):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=89=8D=E7=AB=AF=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/webui/ofdgo.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/assets/webui/ofdgo.js b/assets/webui/ofdgo.js index ab021a3..cc68834 100644 --- a/assets/webui/ofdgo.js +++ b/assets/webui/ofdgo.js @@ -1309,9 +1309,14 @@ function pageShell(index) { function scrollToPage(index) { const shell = pageShell(index); if (shell) { - shell.scrollIntoView({ block: state.fitMode === "height" ? "center" : "start", inline: "nearest" }); - if (state.fitMode !== "height") { - el.viewerPanel.scrollTop = Math.max(0, el.viewerPanel.scrollTop - pageBlockSpace()); + if (state.fitMode === "height") { + shell.scrollIntoView({ block: "center", inline: "nearest" }); + } else { + const viewerRect = el.viewerPanel.getBoundingClientRect(); + const shellRect = shell.getBoundingClientRect(); + const top = el.viewerPanel.scrollTop + shellRect.top - viewerRect.top - pageBlockSpace(); + const maxTop = Math.max(0, el.viewerPanel.scrollHeight - el.viewerPanel.clientHeight); + el.viewerPanel.scrollTop = Math.min(maxTop, Math.max(0, top)); } centerPageInline(shell); }