diff --git a/src/lib/components/Carousel.svelte b/src/lib/components/Carousel.svelte index b26229c..4eb0777 100644 --- a/src/lib/components/Carousel.svelte +++ b/src/lib/components/Carousel.svelte @@ -12,13 +12,20 @@ let carousel = $state(); let scrollPosition = $state(0); let scrollWidth = $state(0); - let clientWidth = $state(0); + let clientWidth = $state(1); function updateScroll() { scrollPosition = carousel?.scrollLeft || 0; scrollWidth = carousel?.scrollWidth || 0; - clientWidth = carousel?.clientWidth || 0; + clientWidth = carousel?.clientWidth || 1; } - onMount(updateScroll); + onMount(() => { + const id = setInterval(() => { + if (carousel) { + updateScroll(); + } + }, 1000); + return () => clearInterval(id); + });
@@ -37,7 +44,8 @@ {#if scrollPosition > clientWidth / 2}