diff --git a/src/components/HorizontalScroller/HorizontalScroller.mdx b/src/components/HorizontalScroller/HorizontalScroller.mdx
index 436f6c6d..8a75c884 100644
--- a/src/components/HorizontalScroller/HorizontalScroller.mdx
+++ b/src/components/HorizontalScroller/HorizontalScroller.mdx
@@ -2,6 +2,8 @@ import { Meta } from '@storybook/blocks';
import * as HorizontalScrollerStories from './HorizontalScroller.stories.svelte';
+import IllustratorScreenshot from './assets/illustrator.png';
+
# HorizontalScroller
@@ -161,7 +163,10 @@ respect_height: true
allow_overflow: true
```
-This can be useful to even transition tagged content inside the ai2svelte graphic as part of the horizontal scrolling experience. For example, caption boxes exported as `htext` tagged layers can be animated to fade in/out or move in/out of view based on the scroll progress. Or one could even use tagged `png` layers to create parallax effects.
+
[Demo](?path=/story/components-graphics-horizontalscroller--scrollable-ai-2-svelte)
@@ -170,9 +175,85 @@ This can be useful to even transition tagged content inside the ai2svelte graphi
import { HorizontalScroller } from '@reuters-graphics/graphics-components';
import AiGraphic from './ai2svelte/ai-graphic.svelte';
import { sineInOut } from 'svelte/easing';
+ // If using with the graphics kit
+ import { assets } from '$app/paths';
+
+
+
+
+
+```
+
+## With ai2svelte components (advanced)
+
+Binding the scrollProgress can be useful to even transition tagged content inside the ai2svelte graphic as part of the horizontal scrolling experience. For example, caption boxes exported as `htext` tagged layers can be animated to fade in/out or move in/out of view based on the scroll progress. Or one could even use tagged `png` layers to create parallax effects.
+
+[Demo](?path=/story/components-graphics-horizontalscroller--scrollable-ai-2-svelte-advanced)
+
+```svelte
+
-
+
```
diff --git a/src/components/HorizontalScroller/HorizontalScroller.stories.svelte b/src/components/HorizontalScroller/HorizontalScroller.stories.svelte
index 597ecd83..f494b6a1 100644
--- a/src/components/HorizontalScroller/HorizontalScroller.stories.svelte
+++ b/src/components/HorizontalScroller/HorizontalScroller.stories.svelte
@@ -6,6 +6,7 @@
import DemoSnippetBlock from './demo/DemoSnippet.svelte';
import CustomChildrenBlock from './demo/CustomChildrenSnippet.svelte';
import ScrollableGraphic from './demo/ScrollableGraphic.svelte';
+ import AdvancedScrollableGraphic from './demo/AdvancedScrollableGraphic.svelte';
import WithScrollerBaseComponent from './demo/withScrollerBase.svelte';
import Block from '../Block/Block.svelte';
@@ -43,6 +44,22 @@
{/snippet}
+
+ {#snippet children(args)}
+
+ {/snippet}
+
+
+
+
+
+
diff --git a/src/components/HorizontalScroller/HorizontalScroller.svelte b/src/components/HorizontalScroller/HorizontalScroller.svelte
index b58e342a..47693b8a 100644
--- a/src/components/HorizontalScroller/HorizontalScroller.svelte
+++ b/src/components/HorizontalScroller/HorizontalScroller.svelte
@@ -99,15 +99,22 @@
let translateX: number = $derived.by(() => {
let processedProgress = progressTween.current;
+ let normalisedProgress = processedProgress;
if (clampedProgress) {
processedProgress = Math.min(
Math.max(progressTween.current, clampStart),
clampEnd
);
- }
- const normalisedProgress =
- direction === 'right' ? processedProgress : 1 - processedProgress;
+ processedProgress = map(processedProgress, 0, 1, clampStart, clampEnd);
+ normalisedProgress =
+ direction === 'right' ? processedProgress : (
+ clampEnd - processedProgress
+ );
+ } else {
+ normalisedProgress =
+ direction === 'right' ? processedProgress : 1 - processedProgress;
+ }
const translate = -(contentWidth - containerWidth) * normalisedProgress;
diff --git a/src/components/HorizontalScroller/assets/illustrator.png b/src/components/HorizontalScroller/assets/illustrator.png
new file mode 100644
index 00000000..9b88eadd
Binary files /dev/null and b/src/components/HorizontalScroller/assets/illustrator.png differ
diff --git a/src/components/HorizontalScroller/demo/AdvancedScrollableGraphic.svelte b/src/components/HorizontalScroller/demo/AdvancedScrollableGraphic.svelte
new file mode 100644
index 00000000..46ff33f6
--- /dev/null
+++ b/src/components/HorizontalScroller/demo/AdvancedScrollableGraphic.svelte
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+ Destruction!
Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
+ caption2:
+ 'Destruction!
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
',
+ caption3:
+ 'Destruction!
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
',
+ caption4:
+ 'Destruction!
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
',
+ },
+ },
+ }}
+ />
+
+
+
+
+
diff --git a/src/components/HorizontalScroller/demo/DemoSnippet.svelte b/src/components/HorizontalScroller/demo/DemoSnippet.svelte
index c4defbda..c03c1ff7 100644
--- a/src/components/HorizontalScroller/demo/DemoSnippet.svelte
+++ b/src/components/HorizontalScroller/demo/DemoSnippet.svelte
@@ -1,4 +1,4 @@
-
+

{
- let captionWidth = caption.getBoundingClientRect().width;
- let captionMidpoint =
- caption.getBoundingClientRect().left + captionWidth / 2;
-
- if (captionMidpoint < screenWidth * threshold) {
- caption.style.opacity = '1';
- } else {
- caption.style.opacity = '0';
- }
- });
- }
- }
-
- function onArtboardChange(artboard: HTMLElement) {
- pngLayer = artboard.querySelector('.g-png-layer-overlay');
- captions = Array.from(artboard.querySelectorAll('.g-captions'));
-
- if (pngLayer) {
- window.removeEventListener('scroll', handleScroll);
- window.addEventListener('scroll', handleScroll, {
- passive: true,
- });
- }
- }
-
-
- Destruction!
Lorem ipsum dolor sit amet, consectetur adipiscing elit. ',
- caption2:
- '
Destruction!
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
',
- caption3:
- '
Destruction!
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
',
- caption4:
- '
Destruction!
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
',
- },
- },
- }}
- />
+