mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
💄 帮助展现位置
This commit is contained in:
parent
3b9ae96dbd
commit
a043604e54
3 changed files with 6 additions and 13 deletions
|
|
@ -34,7 +34,7 @@ export abstract class Constants {
|
||||||
public static readonly SIYUAN_EXPORT_PREVENT: string = "siyuan-export-prevent";
|
public static readonly SIYUAN_EXPORT_PREVENT: string = "siyuan-export-prevent";
|
||||||
|
|
||||||
// size
|
// 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_GET_MAX = 102400;
|
||||||
public static readonly SIZE_UNDO = 64;
|
public static readonly SIZE_UNDO = 64;
|
||||||
public static readonly SIZE_TITLE = 512;
|
public static readonly SIZE_TITLE = 512;
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ export const initStatus = () => {
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
const rect = target.getBoundingClientRect();
|
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();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
} else if (target.classList.contains("b3-menu__item")) {
|
} else if (target.classList.contains("b3-menu__item")) {
|
||||||
|
|
|
||||||
|
|
@ -4,22 +4,15 @@ export const setPosition = (element: HTMLElement, x: number, y: number, targetHe
|
||||||
element.style.top = y + "px";
|
element.style.top = y + "px";
|
||||||
element.style.left = x + "px";
|
element.style.left = x + "px";
|
||||||
const rect = element.getBoundingClientRect();
|
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;
|
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";
|
element.style.top = top + "px";
|
||||||
} else if (top <= dragBarHeight) {
|
} else if (top <= Constants.SIZE_TOOLBAR_HEIGHT) {
|
||||||
// 位置超越到屏幕上方外时,需移动到屏幕顶部。eg:光标在第一个块,然后滚动到上方看不见的位置,按 ctrl+a
|
// 位置超越到屏幕上方外时,需移动到屏幕顶部。eg:光标在第一个块,然后滚动到上方看不见的位置,按 ctrl+a
|
||||||
element.style.top = dragBarHeight + "px";
|
element.style.top = Constants.SIZE_TOOLBAR_HEIGHT + "px";
|
||||||
} else {
|
} else {
|
||||||
// 依旧展现在下部,只是位置上移
|
// 依旧展现在下部,只是位置上移
|
||||||
element.style.top = Math.max(Constants.SIZE_TOOLBAR_HEIGHT, window.innerHeight - rect.height) + "px";
|
element.style.top = Math.max(Constants.SIZE_TOOLBAR_HEIGHT, window.innerHeight - rect.height) + "px";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue