mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 12:47:48 +01:00
The launcher knew its corner, an offset, a global data-fc-bottom and one foreign fixed launcher. Everything else it could miss: any layer wider than 90% of the viewport was ignored, so on substrata /atlas at 390px it parked on the country bottom sheet; and it re-measured only on load, resize, window scroll and URL change, so a sheet mounted later was never seen. One engine now, for every width and obstacle: - placement.slotOrder: preferred corner up its near band, the mirrored corner, then the rest of each edge (pure, unit-tested). - host-scan: hit-tests each slot (launcher + 12px gap) with elementsFromPoint and judges free / surface / layer / blocked. Controls (incl. [tabindex], iframes, cursor:pointer) block; fixed/sticky bars and inner scroll panels are layers; a control >=25% of the viewport (a pannable map) is a surface. - placement.chooseSlot: first free, else least-bad, else HIDE - never sit on a control. - Re-measures on DOM mutation (throttled 1/s) and on inner-panel scroll. - Host contract: data-fc-avoid (never overlap), data-fc-place= left|right|hidden on <html> or a page region. Documented in widget/README.md. Also fixes a latent bug the browser test caught: clearing inline edges to "" let the shadow stylesheet's right:16px survive a move to a LEFT corner, so "Move to other corner" stretched the launcher across the page. Tests: widget-placement.ts (pure) and widget-host-avoid-browser.ts (real Chromium, 9 fixtures). Against the pre-fix bundle 7 assertions fail; each new rule (layer, surface) fails its fixture when mutated out. CI installs chromium-headless-shell so the browser test runs rather than skips. Signed-off-by: Cato <41178744+catomean@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>