From 200196303587ab549293d487df81f9c08f2a5375 Mon Sep 17 00:00:00 2001 From: Nathan Cummins Date: Fri, 16 Oct 2026 12:32:07 +1030 Subject: [PATCH] Reset carousels on page load, tidy navbar state across transitions, proper preloading for carousels --- src/components/ImageCarousel.astro | 56 +++++++++++++++++++++++------- src/components/Navbar.astro | 6 +++- src/pages/index.astro | 4 +-- 3 files changed, 51 insertions(+), 15 deletions(-) diff --git a/src/components/ImageCarousel.astro b/src/components/ImageCarousel.astro index 60d9e6e..f0a8b63 100644 --- a/src/components/ImageCarousel.astro +++ b/src/components/ImageCarousel.astro @@ -43,6 +43,9 @@ const { } = Astro.props as Props; const imagesArray = shuffle ? shuffleArray(images) : images; + +// Slides kept in the layout (first visible, rest preloaded) so their eager loads actually fire; anything past this stays hidden until its turn. +const preloadCount = Math.max(eagerCount, 2); ---
@@ -60,7 +63,7 @@ const imagesArray = shuffle ? shuffleArray(images) : images; transitionStyle, transitionDuration, index > 0 ? "opacity-0" : "", - index < 2 ? "" : "hidden" + index < preloadCount ? "" : "hidden" ]} src={image} alt={ @@ -89,27 +92,53 @@ const imagesArray = shuffle ? shuffleArray(images) : images;
diff --git a/src/components/Navbar.astro b/src/components/Navbar.astro index dd094be..b1dd646 100644 --- a/src/components/Navbar.astro +++ b/src/components/Navbar.astro @@ -64,7 +64,7 @@ const { navbarDisplay = "normal" } = Astro.props as Props;