diff --git a/src/components/PageShell.tsx b/src/components/PageShell.tsx index cf5f4b2..8951eaf 100644 --- a/src/components/PageShell.tsx +++ b/src/components/PageShell.tsx @@ -111,21 +111,32 @@ const circleSize = (box: { width: number; height: number }) => const STICK = "calc(var(--header-h, 5rem) + 1rem)"; const LIST_TOP = 32; const LIST_LEFT = 16; +/* How far left of the list's center the circle sits. */ +const CIRCLE_SHIFT = 24; export default function PageShell({ title, intro, sections, sideNav = false }: PageShellProps) { // The list's measured box, so its circle can center on it from a // layer of its own (below). + // The column's width too: the circle keeps its right edge inside + // it, sliding off the screen's left edge instead when the window + // narrows. const listRef = useRef(null); + const columnRef = useRef(null); const [listBox, setListBox] = useState<{ width: number; height: number } | null>(null); + const [columnWidth, setColumnWidth] = useState(0); useEffect(() => { - const el = listRef.current; - if (!el) return; - const ro = new ResizeObserver(([entry]) => - setListBox({ width: entry.borderBoxSize[0].inlineSize, height: entry.borderBoxSize[0].blockSize }), - ); - ro.observe(el); + const list = listRef.current; + const column = columnRef.current; + if (!list || !column) return; + const ro = new ResizeObserver(() => { + setListBox({ width: list.offsetWidth, height: list.offsetHeight }); + setColumnWidth(column.offsetWidth); + }); + ro.observe(list); + ro.observe(column); return () => ro.disconnect(); }, [sideNav]); + const circle = listBox && circleSize(listBox); // The tab's title as the visitor moves around. The first load's // comes from the server (pageMeta.js), which also sets the page's @@ -160,12 +171,14 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P {sideNav ? (
{/* The margin left of the content (72rem, its text 1.5rem in), - clipping anything wider so the circle never reaches the - content. clip, not hidden: hidden would make it a scroll - container, and the sticky layers in it would stop - sticking. */} + clipping sideways only (the circle shows above and below + the list, past the column's top), so nothing reaches the + content or the screen's edge. clip, not hidden: hidden + would make it a scroll container, and the sticky layers in + it would stop sticking. */}