From e0be2e345a55f852a6cbd892da847029ad614b2c Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 7 Oct 2022 20:08:39 +0800 Subject: [PATCH] :iphone: https://github.com/siyuan-note/siyuan/issues/6074 --- app/src/mobile/util/showKeyboardToolbar.ts | 9 +++++++-- app/src/util/highlightById.ts | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/mobile/util/showKeyboardToolbar.ts b/app/src/mobile/util/showKeyboardToolbar.ts index 622ceccca..9281f458d 100644 --- a/app/src/mobile/util/showKeyboardToolbar.ts +++ b/app/src/mobile/util/showKeyboardToolbar.ts @@ -19,9 +19,14 @@ export const showKeyboardToolbar = (bottom = 0) => { return; } - setTimeout(() => { // Android 端事件需要滞后一些,所以这里统一延迟一下 + if ("android" === window.siyuan.config.system.container && window.JSAndroid) { + // Android 端事件需要滞后一些,所以这里统一延迟一下 + setTimeout(() => { + scrollCenter(window.siyuan.mobileEditor.protyle, undefined, false, (window.outerHeight - 65) / 2 - 30); + }, 100); + } else { scrollCenter(window.siyuan.mobileEditor.protyle, undefined, false, (window.outerHeight - 65) / 2 - 30); - }, 100); + } }; export const hideKeyboardToolbar = () => { diff --git a/app/src/util/highlightById.ts b/app/src/util/highlightById.ts index 95e6994ec..e97e70ffb 100644 --- a/app/src/util/highlightById.ts +++ b/app/src/util/highlightById.ts @@ -44,10 +44,10 @@ export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = fal const cursorTop = getSelectionPosition(editorElement).top - editorElement.getBoundingClientRect().top; if (offset) { // 仅移动端弹起键盘用到 editorElement.scroll({ - top: editorElement.scrollLeft, - left: editorElement.scrollTop + cursorTop - offset, + top: editorElement.scrollTop + cursorTop - offset, + left: editorElement.scrollLeft, behavior: "smooth" - }) + }); return; } if (cursorTop < 0) {