From 83ab2f92246d02b9ba293a0026027cd15e60b86d Mon Sep 17 00:00:00 2001 From: Sudev Kiyada Date: Fri, 9 Jan 2026 11:54:55 +0530 Subject: [PATCH] Get rid of ClampedProgress --- .../HorizontalScroller/Debug.svelte | 61 +++++++-- .../HorizontalScroller/HorizontalScroller.mdx | 2 + .../HorizontalScroller.stories.svelte | 12 +- .../HorizontalScroller.svelte | 124 ++++++++---------- .../demo/DemoSnippet.svelte | 4 +- 5 files changed, 115 insertions(+), 88 deletions(-) diff --git a/src/components/HorizontalScroller/Debug.svelte b/src/components/HorizontalScroller/Debug.svelte index d24e01e5..c6b5be70 100644 --- a/src/components/HorizontalScroller/Debug.svelte +++ b/src/components/HorizontalScroller/Debug.svelte @@ -1,4 +1,6 @@ @@ -58,11 +90,12 @@ > {/each} {:else} - {#each componentState.triggerStops as stop, index} - {#if index < componentState.triggerStops.length - 1} + {@const stops = componentState.triggerStops.map((x) => mappedStop(x))} + {#each stops as stop, index} + {#if index < stops.length - 1} | {/if} @@ -86,6 +119,14 @@ CONSOLE
+ +

Raw progress:

+
+

+ {componentState.rawProgress} +

+
+

Scroll progress:

@@ -93,14 +134,14 @@ {@render triggerPoints()} {fmt.format(componentState.scrollProgress)}  

@@ -110,20 +151,20 @@

{#if componentState.stops.length > 0} {#each componentState.stops as stop} - {stop} + {stop} {/each} {/if} {fmt.format(componentState.progress)}  

-
+
diff --git a/src/components/HorizontalScroller/HorizontalScroller.mdx b/src/components/HorizontalScroller/HorizontalScroller.mdx index 8a75c884..55b78b41 100644 --- a/src/components/HorizontalScroller/HorizontalScroller.mdx +++ b/src/components/HorizontalScroller/HorizontalScroller.mdx @@ -18,6 +18,8 @@ To use the `HorizontalScroller` component, import it and provide the children co > 💡TIP: Use `lvh` or `svh` units instead of `vh` unit for the height, as [these units](https://www.w3.org/TR/css-values-4/#large-viewport-size) are more reliable on mobile or other devices where elements such as the address bar toggle between being shown and hidden. +Use `showDebugInfo` prop to visualize the scroll progress and other useful debug information. The `Raw progress` indicates the vertical progress with values in the range 0...1 indicating the content being locked. The `Scroll Progress` value indicates the vertical progress mapped to clampStart and clampEnd values. By default these are 0 and 1 respectively. Finally, the `Progress` value indicates the horizontal scroll progress after applying stops and easing (if any). + [Demo](?path=/story/components-graphics-horizontalscroller--demo) ```svelte diff --git a/src/components/HorizontalScroller/HorizontalScroller.stories.svelte b/src/components/HorizontalScroller/HorizontalScroller.stories.svelte index f494b6a1..1e58a827 100644 --- a/src/components/HorizontalScroller/HorizontalScroller.stories.svelte +++ b/src/components/HorizontalScroller/HorizontalScroller.stories.svelte @@ -45,14 +45,16 @@ {#snippet children(args)} @@ -67,7 +69,7 @@ height: '200lvh', stops: [0.2, 0.5, 0.6, 0.7], duration: 400, - scrubbed: false, + scrubbed: true, easing: quartInOut, showDebugInfo: true, direction: 'left', diff --git a/src/components/HorizontalScroller/HorizontalScroller.svelte b/src/components/HorizontalScroller/HorizontalScroller.svelte index 47693b8a..4664d5a8 100644 --- a/src/components/HorizontalScroller/HorizontalScroller.svelte +++ b/src/components/HorizontalScroller/HorizontalScroller.svelte @@ -1,5 +1,5 @@