Merge remote-tracking branches 'origin/sub_laptop_2', 'origin/sub_laptop_7' and 'origin/sub_laptop_8' into sub_laptop_5

This commit is contained in:
2026-10-08 13:38:09 +09:00
8 changed files with 82 additions and 25 deletions
+14 -7
View File
@@ -113,6 +113,18 @@ export function createMapContextMenu(blockClass: string): MapContextMenu {
return entry;
}
/** 화면 밖으로 나가면 안쪽으로 당김(오른쪽 · 아래 끝) — 열 때 · 하위 메뉴를 펼칠 때 */
function fit(): void {
const x = parseFloat(element.style.left);
const y = parseFloat(element.style.top);
const box = element.getBoundingClientRect();
const view = element.ownerDocument.defaultView ?? window; // 새 창에 옮겨진 패널(54-35)
const dx = Math.max(0, box.right - view.innerWidth + 4);
const dy = Math.max(0, box.bottom - view.innerHeight + 4);
if (dx) element.style.left = `${Math.max(x - dx, x - box.left)}px`;
if (dy) element.style.top = `${Math.max(y - dy, y - box.top)}px`;
}
return {
element,
open(x, y, items) {
@@ -152,6 +164,7 @@ export function createMapContextMenu(blockClass: string): MapContextMenu {
.forEach((other) => (other.textContent = other.textContent!.replace("▾", "▸")));
body.hidden = !willOpen;
head.textContent = `${item.label} ${willOpen ? "▾" : "▸"}`;
fit(); // 펼친 하위가 화면 아래로 넘치면 메뉴를 올림
});
element.append(head, body);
});
@@ -160,13 +173,7 @@ export function createMapContextMenu(blockClass: string): MapContextMenu {
element.style.left = `${x}px`;
element.style.top = `${y}px`;
element.hidden = false;
// 화면 밖으로 나가면 안쪽으로 당김(오른쪽 · 아래 끝에서 연 메뉴)
const box = element.getBoundingClientRect();
const view = element.ownerDocument.defaultView ?? window; // 새 창에 옮겨진 패널(54-35)
const dx = Math.max(0, box.right - view.innerWidth + 4);
const dy = Math.max(0, box.bottom - view.innerHeight + 4);
if (dx) element.style.left = `${Math.max(x - dx, x - box.left)}px`;
if (dy) element.style.top = `${Math.max(y - dy, y - box.top)}px`;
fit();
},
close,
contains: (target) => target instanceof Node && element.contains(target),