diff --git a/B06_Section/B06_Section_UI_Cross_Structure_Panel.ts b/B06_Section/B06_Section_UI_Cross_Structure_Panel.ts index 02db256f..8e86f65d 100644 --- a/B06_Section/B06_Section_UI_Cross_Structure_Panel.ts +++ b/B06_Section/B06_Section_UI_Cross_Structure_Panel.ts @@ -108,6 +108,21 @@ export function buildStructurePanel(deps: StructurePanelDeps): StructurePanelHan root.addEventListener("scroll", () => { if (!root.classList.contains("is-hidden")) panelScrollTops.set(deps.scrollKey, root.scrollTop); }); + /** + * 기억해 둔 스크롤 자리를 되살린다. 카드를 다시 그릴 때 창은 **카드가 문서에 + * 붙기 전에** 만들어지므로 그 순간의 대입은 레이아웃이 없어 먹지 않는다 + * (2026-08-29 사용자: 값 조절만 해도 창이 제목 줄로 튀던 원인). 대입이 먹지 + * 않았으면 붙은 다음 프레임에 한 번 더 넣는다. + */ + const restoreScroll = (): void => { + const saved = panelScrollTops.get(deps.scrollKey); + if (!saved) return; + root.scrollTop = saved; + if (root.scrollTop === saved) return; + requestAnimationFrame(() => { + if (root.isConnected && !root.classList.contains("is-hidden")) root.scrollTop = saved; + }); + }; // 창 안에서의 클릭이 카드 선택으로 번지지 않게 한 번에 막는다. root.addEventListener("click", (event) => event.stopPropagation()); @@ -568,8 +583,7 @@ export function buildStructurePanel(deps: StructurePanelDeps): StructurePanelHan : "0m"); // 행 표시가 다 끝난 뒤에 되살린다 — 숨김 토글로 창 높이가 바뀌기 전에 넣으면 // 브라우저가 잘라 버린다. - const saved = panelScrollTops.get(deps.scrollKey); - if (saved) root.scrollTop = saved; + restoreScroll(); }, }; }