From 9199ae02d8db0672807711d90ba34264a8c3a465 Mon Sep 17 00:00:00 2001 From: xiaoqidun Date: Wed, 8 Jul 2026 21:19:51 +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=96OFDGo=20WebUI=E9=80=82=E9=AB=98=E3=80=81?= =?UTF-8?q?=E9=80=82=E5=AE=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/webui/ofdgo.css | 2 ++ assets/webui/ofdgo.js | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/assets/webui/ofdgo.css b/assets/webui/ofdgo.css index 2aa4e77..0dc5fdc 100644 --- a/assets/webui/ofdgo.css +++ b/assets/webui/ofdgo.css @@ -472,6 +472,8 @@ body[data-hide-meta] .meta-panel { } .page-frame { + display: grid; + align-items: safe center; min-width: 100%; min-height: 100%; padding: var(--page-space); diff --git a/assets/webui/ofdgo.js b/assets/webui/ofdgo.js index b7970a9..d7fea27 100644 --- a/assets/webui/ofdgo.js +++ b/assets/webui/ofdgo.js @@ -1197,6 +1197,9 @@ 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 - pageSpace()); + } } } @@ -1838,9 +1841,13 @@ function fitWidth(updateStatus = true) { return; } state.fitMode = "width"; - const available = Math.max(280, el.pageFrame.clientWidth - pageSpace() * 2); + const space = pageSpace(); + const available = Math.max(1, el.viewerPanel.clientWidth - space * 2); const width = Math.max(1, page.width * MM_TO_PX); setScale(available / width, updateStatus, "width"); + if (updateStatus) { + scrollToPage(state.pageIndex); + } } function fitHeight(updateStatus = true) { @@ -1849,9 +1856,12 @@ function fitHeight(updateStatus = true) { return; } state.fitMode = "height"; - const available = Math.max(220, el.viewerPanel.clientHeight - pageSpace() * 2); + const space = pageSpace(); + const availableWidth = Math.max(1, el.viewerPanel.clientWidth - space * 2); + const availableHeight = Math.max(1, el.viewerPanel.clientHeight - space * 2); + const width = Math.max(1, page.width * MM_TO_PX); const height = Math.max(1, page.height * MM_TO_PX); - setScale(available / height, updateStatus, "height"); + setScale(Math.min(availableWidth / width, availableHeight / height), updateStatus, "height"); if (updateStatus) { scrollToPage(state.pageIndex); }