Merge pull request #283 from reuters-graphics/bindable-props

Bindable props for Scroller
This commit is contained in:
Sudev Kiyada 2025-04-22 23:03:59 +05:30 committed by GitHub
commit 3753966494
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 5 deletions

View file

@ -0,0 +1,5 @@
---
'@reuters-graphics/graphics-components': patch
---
Exposes bindable props for the Scroller component

View file

@ -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)',
},
},
},
});
</script>

View file

@ -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);
</script>
{#if !embedded}