From b0f674d84ca88854eaaef9c6b18624bdb1a5b137 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 14 Dec 2025 19:57:09 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/16429 --- app/src/util/highlightById.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/util/highlightById.ts b/app/src/util/highlightById.ts index 7f4cd9259..1ef92d030 100644 --- a/app/src/util/highlightById.ts +++ b/app/src/util/highlightById.ts @@ -111,14 +111,15 @@ export const scrollCenter = ( } if (position === "nearest") { // 在可视区域内不进行滚动 - if (elementRect.top < contentRect.top) { + if (elementRect.bottom < contentRect.top) { protyle.contentElement.scroll({ top: protyle.contentElement.scrollTop + elementRect.top - contentRect.top, behavior }); - } else if (elementRect.bottom > contentRect.bottom) { + } else if (elementRect.top > contentRect.bottom) { protyle.contentElement.scroll({ - top: protyle.contentElement.scrollTop + elementRect.bottom - contentRect.bottom, + top: elementRect.height > contentRect.height ? protyle.contentElement.scrollTop + elementRect.top - contentRect.top : + protyle.contentElement.scrollTop + elementRect.bottom - contentRect.bottom, behavior }); }