mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-21 19:41:05 +08:00
📱 高度计算
This commit is contained in:
parent
8979a8f840
commit
5a68a8c65f
@ -145,7 +145,7 @@ window.reconnectWebSocket = () => {
|
|||||||
};
|
};
|
||||||
window.goBack = goBack;
|
window.goBack = goBack;
|
||||||
window.showKeyboardToolbar = (height) => {
|
window.showKeyboardToolbar = (height) => {
|
||||||
document.getElementById("keyboardToolbar").setAttribute("data-keyboardheight", (height ? height : window.innerHeight / 2 - 42).toString());
|
document.getElementById("keyboardToolbar").setAttribute("data-keyboardheight", (height ? height : window.outerHeight / 2 - 42).toString());
|
||||||
showKeyboardToolbar();
|
showKeyboardToolbar();
|
||||||
};
|
};
|
||||||
window.hideKeyboardToolbar = hideKeyboardToolbar;
|
window.hideKeyboardToolbar = hideKeyboardToolbar;
|
||||||
|
@ -273,7 +273,7 @@ export const showKeyboardToolbarUtil = (oldScrollTop: number) => {
|
|||||||
|
|
||||||
const toolbarElement = document.getElementById("keyboardToolbar");
|
const toolbarElement = document.getElementById("keyboardToolbar");
|
||||||
let keyboardHeight = toolbarElement.getAttribute("data-keyboardheight");
|
let keyboardHeight = toolbarElement.getAttribute("data-keyboardheight");
|
||||||
keyboardHeight = (keyboardHeight ? (parseInt(keyboardHeight) + 42) : window.innerHeight / 2) + "px";
|
keyboardHeight = (keyboardHeight ? (parseInt(keyboardHeight) + 42) : window.outerHeight / 2) + "px";
|
||||||
const editor = getCurrentEditor();
|
const editor = getCurrentEditor();
|
||||||
if (editor) {
|
if (editor) {
|
||||||
editor.protyle.element.parentElement.style.paddingBottom = keyboardHeight;
|
editor.protyle.element.parentElement.style.paddingBottom = keyboardHeight;
|
||||||
@ -415,12 +415,13 @@ export const showKeyboardToolbar = () => {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const contentElement = hasClosestByClassName(range.startContainer, "protyle-content", true);
|
const contentElement = hasClosestByClassName(range.startContainer, "protyle-content", true);
|
||||||
if (contentElement) {
|
if (contentElement) {
|
||||||
const cursorTop = getSelectionPosition(contentElement).top - contentElement.getBoundingClientRect().top;
|
const contentTop = contentElement.getBoundingClientRect().top;
|
||||||
if (cursorTop < window.innerHeight - 118.5) { // 118: contentElement.getBoundingClientRect().top + toolbarElement.clientHeight
|
const cursorTop = getSelectionPosition(contentElement).top;
|
||||||
|
if (cursorTop < window.innerHeight - 42 && cursorTop > contentTop) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
contentElement.scroll({
|
contentElement.scroll({
|
||||||
top: contentElement.scrollTop + cursorTop - ((window.outerHeight - 118.5) / 2 - 26),
|
top: contentElement.scrollTop + cursorTop - window.innerHeight + 42 + 26,
|
||||||
left: contentElement.scrollLeft,
|
left: contentElement.scrollLeft,
|
||||||
behavior: "smooth"
|
behavior: "smooth"
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user