diff --git a/src/components/Scroller/Background.svelte b/src/components/Scroller/Background.svelte index 337a3c15..4df7102c 100644 --- a/src/components/Scroller/Background.svelte +++ b/src/components/Scroller/Background.svelte @@ -9,16 +9,26 @@ } let { index, steps, preload = 1, stackBackground = true }: Props = $props(); + + function shouldShowStep(i:number) { + if (preload === 0) return true; + if (stackBackground) return i <= index; + return i >= index - preload && i <= index + preload; + } + + function isStepVisible(i:number) { + if (stackBackground) return i <= index; + return i === index; + } + {#each steps as step, i} - - - {#if preload === 0 || (i >= (stackBackground ? 0 : index - preload) && i <= index + preload)} + {#if shouldShowStep(i)}