Files
Aislo/B07_DesignDetail/openwebcad/src/integration/host-burger.ts
T

20 lines
898 B
TypeScript

/**
* 앱 ☰ 자리 비키기(기기대응 7-2) — 앱(B07)이 왼쪽 위에 띄운 ☰ 가 이 틀(iframe) 맨 위 줄에 걸치면
* 걸친 폭 + 틈 8 을 `--host-burger-pad` 로 적음(App.css `.cad-titlebar` 가 그만큼 왼쪽을 비움).
* 좌측 패널을 여닫으면 틀 폭이 바뀌어 resize 로 다시 잼 · 홀로 띄운 CAD(틀 없음)는 0.
*/
import './host-burger.css';
export function registerHostBurgerPad(): void {
const frame = window.frameElement;
if (!frame) return;
const update = (): void => {
const b = frame.ownerDocument.querySelector('.app-burger')?.getBoundingClientRect();
const f = frame.getBoundingClientRect();
const pad = b?.width && b.bottom > f.top ? Math.max(0, Math.ceil(b.right + 8 - f.left)) : 0;
document.documentElement.style.setProperty('--host-burger-pad', `${pad}px`);
};
update();
window.addEventListener('resize', update);
}