diff --git a/src/routes/Commits.svelte b/src/routes/Commits.svelte index 6c45bdd..2aca432 100644 --- a/src/routes/Commits.svelte +++ b/src/routes/Commits.svelte @@ -97,6 +97,7 @@ if (rows.length !== currentItems.length) return; const containerRect = containerEl.getBoundingClientRect(); + const listRect = listEl.getBoundingClientRect(); nodePositions = rows.map((row) => { const card = row.children[1] as HTMLElement; @@ -108,7 +109,10 @@ }; }); - graphHeight = containerEl.scrollHeight; + // Measure the list instead of the container: the absolutely positioned SVG + // is part of the container's scroll height, which would make graphHeight + // grow and never shrink again when the viewport widens. + graphHeight = listRect.bottom - containerRect.top; } // Initial measurement. diff --git a/src/routes/Content.svelte b/src/routes/Content.svelte index 42587d8..95e57d7 100644 --- a/src/routes/Content.svelte +++ b/src/routes/Content.svelte @@ -4,6 +4,7 @@ let { items }: { items: ContentItem[] } = $props(); let containerElement: HTMLDivElement; + let listElement = $state(); let cardElements = $state([]); let graphHeight = $state(0); @@ -14,11 +15,15 @@ const currentItems = items; const cards = cardElements.filter(Boolean); const container = containerElement; + const list = listElement; - if (!container || cards.length !== currentItems.length) return; + if (!container || !list || cards.length !== currentItems.length) return; + + const listEl: HTMLDivElement = list; function updatePositions() { const containerRect = container.getBoundingClientRect(); + const listRect = listEl.getBoundingClientRect(); nodePositions = cards.map((card) => { const rect = card.getBoundingClientRect(); @@ -29,7 +34,10 @@ }; }); - graphHeight = container.scrollHeight; + // Measure the list instead of the container: the absolutely positioned SVG + // is part of the container's scroll height, which would make graphHeight + // grow and never shrink again when the viewport widens. + graphHeight = listRect.bottom - containerRect.top; } // Initial measurement. @@ -90,7 +98,7 @@ -
+
{#each items as item, index (item.link)}