From 0e5b85f8dc57caab1b7ae6ca32e33d634273f3e7 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 7 Nov 2022 23:43:28 +0800 Subject: [PATCH] :art: https://ld246.com/article/1667819182002 --- app/src/mobile/util/showKeyboardToolbar.ts | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/src/mobile/util/showKeyboardToolbar.ts b/app/src/mobile/util/showKeyboardToolbar.ts index dd95a4301..302e21248 100644 --- a/app/src/mobile/util/showKeyboardToolbar.ts +++ b/app/src/mobile/util/showKeyboardToolbar.ts @@ -22,17 +22,19 @@ export const showKeyboardToolbar = (bottom = 0) => { toolbarElement.classList.remove("fn__none"); toolbarElement.style.bottom = bottom + "px"; - const contentElement = window.siyuan.mobileEditor.protyle.contentElement - const cursorTop = getSelectionPosition(contentElement).top - contentElement.getBoundingClientRect().top; - if (cursorTop < window.innerHeight - 96) { - return; - } - contentElement.scroll({ - top: contentElement.scrollTop + cursorTop - ((window.outerHeight - 65) / 2 - 30), - left: contentElement.scrollLeft, - behavior: "smooth" - }); - alert(cursorTop + "," + window.innerHeight); + setTimeout(() => { + const contentElement = window.siyuan.mobileEditor.protyle.contentElement + const cursorTop = getSelectionPosition(contentElement).top - contentElement.getBoundingClientRect().top; + if (cursorTop < window.innerHeight - 96) { + return; + } + contentElement.scroll({ + top: contentElement.scrollTop + cursorTop - ((window.outerHeight - 65) / 2 - 30), + left: contentElement.scrollLeft, + behavior: "smooth" + }); + alert(cursorTop + "," + window.innerHeight); + }) // if ("android" === window.siyuan.config.system.container && window.JSAndroid) { // // Android 端事件需要滞后一些,所以这里延迟一下 // setTimeout(() => {