fixed weird padding at bottom of screen
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
let { items }: { items: ContentItem[] } = $props();
|
||||
|
||||
let containerElement: HTMLDivElement;
|
||||
let listElement = $state<HTMLDivElement>();
|
||||
let cardElements = $state<HTMLElement[]>([]);
|
||||
|
||||
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 @@
|
||||
</svg>
|
||||
|
||||
<!-- Article list -->
|
||||
<div class="mt-3 mr-4 grid grid-flow-row auto-rows-min">
|
||||
<div bind:this={listElement} class="mt-3 mr-4 grid grid-flow-row auto-rows-min">
|
||||
{#each items as item, index (item.link)}
|
||||
<div
|
||||
class="relative z-10 grid grid-cols-[2rem_minmax(0,1fr)] gap-4 pb-3 max-[600px]:grid-cols-[1.25rem_minmax(0,1fr)] max-[600px]:gap-2"
|
||||
|
||||
Reference in New Issue
Block a user