From d73fbcb8fef307194cef4a43128066da0fb74019 Mon Sep 17 00:00:00 2001 From: Thomas Lehmann Date: Thu, 24 Apr 2025 09:28:06 +0200 Subject: [PATCH 1/2] c/fix(Scroller): fix non-auto-starting scroller == Cause The scroller animation did not start because the `animation-duration` property had the value 0 initially. This was caused by `el.scrollWidth` being 0 initially because there were no elements in `items`, which was caused by PromptSelector loading the items asynchroneously on mount. == Fix The reactive expression now incorporates the state of `items` for recalculation. --- src/lib/IONOS/components/explore/Scroller.svelte | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib/IONOS/components/explore/Scroller.svelte b/src/lib/IONOS/components/explore/Scroller.svelte index d5d8b38adf7..5b006f9cce1 100644 --- a/src/lib/IONOS/components/explore/Scroller.svelte +++ b/src/lib/IONOS/components/explore/Scroller.svelte @@ -17,9 +17,15 @@ } } - $: scrollWidth = el?.scrollWidth ?? 0; - $: fullWidth = scrollWidth / 2; - $: duration = fullWidth / speed; + let scrollWidth; + let fullWidth; + let duration; + + $: { + scrollWidth = items.length > 0 ? el?.scrollWidth ?? 0 : 0; + fullWidth = scrollWidth / 2; + duration = fullWidth / speed; + }
Date: Thu, 24 Apr 2025 10:53:22 +0200 Subject: [PATCH 2/2] c/chore(Scroller): declare types --- src/lib/IONOS/components/explore/Scroller.svelte | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lib/IONOS/components/explore/Scroller.svelte b/src/lib/IONOS/components/explore/Scroller.svelte index 5b006f9cce1..972af6d69e7 100644 --- a/src/lib/IONOS/components/explore/Scroller.svelte +++ b/src/lib/IONOS/components/explore/Scroller.svelte @@ -1,13 +1,14 @@