diff --git a/.changeset/huge-moles-watch.md b/.changeset/huge-moles-watch.md new file mode 100644 index 00000000..ebe5dcc8 --- /dev/null +++ b/.changeset/huge-moles-watch.md @@ -0,0 +1,5 @@ +--- +'@reuters-graphics/graphics-components': patch +--- + +Exposes bindable props for the Scroller component diff --git a/src/components/Scroller/Scroller.stories.svelte b/src/components/Scroller/Scroller.stories.svelte index 101b4967..ca233b30 100644 --- a/src/components/Scroller/Scroller.stories.svelte +++ b/src/components/Scroller/Scroller.stories.svelte @@ -19,6 +19,24 @@ control: 'select', options: ['fb', 'bf'], }, + index: { + control: false, + table: { + category: 'Bindable states (Read-only)', + }, + }, + offset: { + control: false, + table: { + category: 'Bindable states (Read-only)', + }, + }, + progress: { + control: false, + table: { + category: 'Bindable states (Read-only)', + }, + }, }, }); diff --git a/src/components/Scroller/Scroller.svelte b/src/components/Scroller/Scroller.svelte index 777cef59..b6c897b2 100644 --- a/src/components/Scroller/Scroller.svelte +++ b/src/components/Scroller/Scroller.svelte @@ -74,6 +74,12 @@ id?: string; /** Set a class to target with SCSS */ class?: string; + /** The currently active section */ + index?: number; + /** How far the section has scrolled past the threshold, as a value between 0 and 1 */ + offset?: number; + /** How far the foreground has travelled, where 0 is the top of the foreground crossing top, and 1 is the bottom crossing bottom */ + progress?: number; } let { @@ -90,12 +96,10 @@ bottom = 1, parallax = false, class: cls = '', + index = $bindable(0), + offset = $bindable(0), + progress = $bindable(0), }: Props = $props(); - - // Bindable variables passed to ScrollerBase - let index = $state(0); - let offset = $state(0); - let progress = $state(0); {#if !embedded}