diff --git a/app/src/constants.ts b/app/src/constants.ts index aa6ae865f..5615f4b46 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -34,7 +34,7 @@ export abstract class Constants { public static readonly SIYUAN_EXPORT_PREVENT: string = "siyuan-export-prevent"; // size - public static readonly SIZE_TOOLBAR_HEIGHT: number = 42; + public static readonly SIZE_TOOLBAR_HEIGHT: number = 32; public static readonly SIZE_GET_MAX = 102400; public static readonly SIZE_UNDO = 64; public static readonly SIZE_TITLE = 512; diff --git a/app/src/layout/status.ts b/app/src/layout/status.ts index 071d5a2b6..dfc952ffc 100644 --- a/app/src/layout/status.ts +++ b/app/src/layout/status.ts @@ -117,7 +117,7 @@ export const initStatus = () => { } }).element); const rect = target.getBoundingClientRect(); - window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, h: rect.height}, true); + window.siyuan.menus.menu.popup({x: rect.right, y: rect.top}, true); event.stopPropagation(); break; } else if (target.classList.contains("b3-menu__item")) { diff --git a/app/src/util/setPosition.ts b/app/src/util/setPosition.ts index 5c90fb762..e0871fd5f 100644 --- a/app/src/util/setPosition.ts +++ b/app/src/util/setPosition.ts @@ -4,22 +4,15 @@ export const setPosition = (element: HTMLElement, x: number, y: number, targetHe element.style.top = y + "px"; element.style.left = x + "px"; const rect = element.getBoundingClientRect(); - // windows 下悬浮菜单在 drag 位置时无法点击 - let dragBarHeight = 0; - /// #if !BROWSER - if ("windows" === window.siyuan.config.system.os) { - dragBarHeight = document.getElementById("drag").clientHeight; - } - /// #endif // 上下超出屏幕 - if (rect.bottom > window.innerHeight || rect.top < dragBarHeight) { + if (rect.bottom > window.innerHeight || rect.top < Constants.SIZE_TOOLBAR_HEIGHT) { const top = y - rect.height - targetHeight; - if (top > dragBarHeight && (top + rect.height) < window.innerHeight - dragBarHeight) { + if (top > Constants.SIZE_TOOLBAR_HEIGHT && (top + rect.height) < window.innerHeight) { // 上部 element.style.top = top + "px"; - } else if (top <= dragBarHeight) { + } else if (top <= Constants.SIZE_TOOLBAR_HEIGHT) { // 位置超越到屏幕上方外时,需移动到屏幕顶部。eg:光标在第一个块,然后滚动到上方看不见的位置,按 ctrl+a - element.style.top = dragBarHeight + "px"; + element.style.top = Constants.SIZE_TOOLBAR_HEIGHT + "px"; } else { // 依旧展现在下部,只是位置上移 element.style.top = Math.max(Constants.SIZE_TOOLBAR_HEIGHT, window.innerHeight - rect.height) + "px";