From 070fef00fa7087ce0739a87b4d06c0f60eea98ee Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 7 Oct 2022 20:00:42 +0800 Subject: [PATCH] :iphone: https://github.com/siyuan-note/siyuan/issues/6074 --- app/src/util/highlightById.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/util/highlightById.ts b/app/src/util/highlightById.ts index fea528f15..95e6994ec 100644 --- a/app/src/util/highlightById.ts +++ b/app/src/util/highlightById.ts @@ -38,12 +38,16 @@ export const highlightById = (protyle: IProtyle, id: string, top = false) => { } }; -export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = false, offset= 0) => { +export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = false, offset = 0) => { if (!top && getSelection().rangeCount > 0 && hasClosestBlock(getSelection().getRangeAt(0).startContainer)) { const editorElement = protyle.contentElement; const cursorTop = getSelectionPosition(editorElement).top - editorElement.getBoundingClientRect().top; if (offset) { // 仅移动端弹起键盘用到 - editorElement.scrollTop = editorElement.scrollTop + cursorTop - offset; + editorElement.scroll({ + top: editorElement.scrollLeft, + left: editorElement.scrollTop + cursorTop - offset, + behavior: "smooth" + }) return; } if (cursorTop < 0) {