Merge remote-tracking branch 'origin/sub_laptop_6' into main_laptop_1

This commit is contained in:
2026-10-05 20:02:23 +09:00
2 changed files with 20 additions and 1 deletions
+10
View File
@@ -185,10 +185,18 @@ function scroller(node: HTMLElement): HTMLElement | null {
*/
function followView(node: HTMLElement): void {
const ref = new WeakRef(node); // 떼었다 다시 붙이는 화면(M01)도 있어 떼어져도 듣기는 남김 · 버려지면 그침
// 다시 붙음 · 칸 내용이 늦게 차 칸 크기가 바뀜(스크롤 없이) → 다시 잼
const sized = new ResizeObserver(() => place());
let watched: Element | null = null;
const place = (): void => {
const root = ref.deref();
if (!root) return stop();
if (!root.isConnected) return;
if (root.parentElement && root.parentElement !== watched) {
if (watched) sized.unobserve(watched);
watched = root.parentElement;
sized.observe(watched);
}
const box = scroller(root)?.getBoundingClientRect();
const head = document.querySelector(".app-header")?.getBoundingClientRect().bottom ?? 0;
const view = Math.max(head, box?.top ?? 0);
@@ -206,8 +214,10 @@ function followView(node: HTMLElement): void {
const stop = (): void => {
window.removeEventListener("scroll", place, true);
window.removeEventListener("resize", place);
sized.disconnect();
};
window.addEventListener("scroll", place, true);
window.addEventListener("resize", place);
sized.observe(node);
setTimeout(place); // 붙은 뒤 한 번
}