diff --git a/src/components/HorizontalScroller/Debug.svelte b/src/components/HorizontalScroller/Debug.svelte index c6b5be70..3a96e9e7 100644 --- a/src/components/HorizontalScroller/Debug.svelte +++ b/src/components/HorizontalScroller/Debug.svelte @@ -48,7 +48,7 @@ let normalisedScrollProgress = $derived( map( - componentState.scrollProgress, + componentState.mappedProgress, componentState.clampStart ?? 0, componentState.clampEnd ?? 1, 0, @@ -58,7 +58,7 @@ let normalisedProgress = $derived( map( - componentState.progress, + componentState.easedProgress, componentState.clampStart ?? 0, componentState.clampEnd ?? 1, 0, @@ -120,22 +120,21 @@
Raw progress:
+Progress:
- {componentState.rawProgress} + {componentState.progress}
Scroll progress:
+Mapped progress:
{@render triggerPoints()} {fmt.format(componentState.scrollProgress)}{fmt.format(componentState.mappedProgress)}
@@ -146,7 +145,7 @@Progress:
+Eased Progress:
{#if componentState.stops.length > 0} @@ -159,7 +158,7 @@ {fmt.format(componentState.progress)}{fmt.format(componentState.easedProgress)}
diff --git a/src/components/HorizontalScroller/HorizontalScroller.mdx b/src/components/HorizontalScroller/HorizontalScroller.mdx index 55b78b41..79c4b51d 100644 --- a/src/components/HorizontalScroller/HorizontalScroller.mdx +++ b/src/components/HorizontalScroller/HorizontalScroller.mdx @@ -18,7 +18,7 @@ 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). +Use `showDebugInfo` prop to visualize the scroll progress and other useful debug information. The `Progress` indicates the vertical progress with values in the range 0...1 indicating the content being locked or a user-fed value to control the horizontal scroll position. The `Mapped Progress` value indicates the vertical progress mapped to mappedStart and mappedEnd values. By default these are 0 and 1 respectively. Finally, the `Eased Progress` value indicates the horizontal scroll progress after applying stops and easing (if any). [Demo](?path=/story/components-graphics-horizontalscroller--demo) @@ -323,7 +323,7 @@ You can also integrate HorizontalScroller with `ScrollerBase` for a horizontal s width="fluid" height="100lvh" direction="right" - bind:scrollProgress={progress} + bind:progress scrubbed stops={[0.5]} handleScroll={false} diff --git a/src/components/HorizontalScroller/HorizontalScroller.stories.svelte b/src/components/HorizontalScroller/HorizontalScroller.stories.svelte index 1e58a827..893fccbc 100644 --- a/src/components/HorizontalScroller/HorizontalScroller.stories.svelte +++ b/src/components/HorizontalScroller/HorizontalScroller.stories.svelte @@ -49,8 +49,8 @@ args={{ children: DemoSnippet, height: '200lvh', - clampStart: -0.5, - clampEnd: 1.5, + mappedStart: -0.5, + mappedEnd: 1.5, showDebugInfo: true, scrubbed: true, stops: [0, 1], diff --git a/src/components/HorizontalScroller/HorizontalScroller.svelte b/src/components/HorizontalScroller/HorizontalScroller.svelte index 4664d5a8..10ae3098 100644 --- a/src/components/HorizontalScroller/HorizontalScroller.svelte +++ b/src/components/HorizontalScroller/HorizontalScroller.svelte @@ -13,7 +13,7 @@ /** Height of the scroller container in CSS `vh` units. Set it to `100lvh` when using inside ScrollerBase. */ height?: string; /** Bindable progress value. Ideal range: `[0-1]`. Bind ScrollerBase's progress to this prop. */ - scrollProgress?: number; + progress?: number; /** Direction of movement*/ direction?: 'left' | 'right'; /** Content to scroll*/ @@ -31,9 +31,9 @@ /** Whether to show debug info */ showDebugInfo?: boolean; /** Modified starting scale. Default is 0 */ - clampStart?: number; + mappedStart?: number; /** Modified ending scale. Default is 1 */ - clampEnd?: number; + mappedEnd?: number; } let { @@ -41,9 +41,9 @@ class: cls = '', height = '200lvh', direction = 'right', - scrollProgress = $bindable(0), - clampStart = 0, - clampEnd = 1, + progress = $bindable(0), + mappedStart = 0, + mappedEnd = 1, children, stops = [], handleScroll = true, @@ -54,22 +54,22 @@ }: Props = $props(); let componentState = $derived.by(() => ({ - scrollProgress, - progress: progressTween.current, + progress, + mappedProgress, + easedProgress: easedProgress.current, direction, - clampStart, - clampEnd, + mappedStart, + mappedEnd, triggerStops: scrubbed ? stops : divisions, stops: stops, handleScroll, scrubbed, easing: ease, duration, - rawProgress, })); - let progressTween: Tween