diff --git a/src/components/ScrollyVideo/Debug.svelte b/src/components/ScrollyVideo/Debug.svelte index 7600672a..547b3f04 100644 --- a/src/components/ScrollyVideo/Debug.svelte +++ b/src/components/ScrollyVideo/Debug.svelte @@ -130,7 +130,7 @@ z-index: 3; margin: 0; width: 50vmin; - min-width: 30vmin; + min-width: 50vmin; padding: 8px; border-radius: 8px; overflow: auto; @@ -178,7 +178,7 @@ display: grid; width: 100%; padding: 8px 8px 16px 8px; - grid-template-columns: 10vmin 1fr; + grid-template-columns: 20vmin 1fr; align-items: center; gap: 0.75rem 0.25rem; background-color: #1e1e1e; diff --git a/src/components/ScrollyVideo/ScrollyVideo.mdx b/src/components/ScrollyVideo/ScrollyVideo.mdx index 2bf50b5a..db69d314 100644 --- a/src/components/ScrollyVideo/ScrollyVideo.mdx +++ b/src/components/ScrollyVideo/ScrollyVideo.mdx @@ -2,7 +2,7 @@ import { Meta } from '@storybook/blocks'; import * as ScrollyVideoStories from './ScrollyVideo.stories.svelte'; -; + # ScrollyVideo @@ -31,7 +31,7 @@ When using the `ScrollyVideo` component, minimise the video file size and ensure To optimise your video for the web, you can use `ffmpeg` to convert the video to a suitable format. Here is an example terminal command that converts a video to H.264 format with a resolution of 720p and a frame rate of 24 FPS: ```bash -npx ffmpeg -y -i .mp4 -c:v libx264 -movflags faststart -crf 20 -r 24 -vf scale=720:-1 -profile:v high -preset veryslow -level:v 4.1 -color_primaries 1 -color_trc 1 -colorspace 1 -an .mp4 +npx ffmpeg -y -i .mp4 -c:v libx264 -movflags faststart -crf 20 -r 24 -vf scale=720:-1 -profile:v baseline -preset veryslow -level:v 4.1 -color_primaries 1 -color_trc 1 -colorspace 1 -an .mp4 ``` Adjust the `-crf` value to control the quality. Lower `-crf` value means higher quality, with 20 being a generally good balance. See [Testing Media Capabilities](https://cconcolato.github.io/media-mime-support/mediacapabilities.html) for more. @@ -126,9 +126,7 @@ With the graphics kit, you'll likely get your text and prop values from an Archi position: bottom center # Position of the text. Optional; defaults to 'center center'. Must be a combination of `top/bottom/center center/left/right` backgroundColour: rgba(0, 0, 0, 0.8) # Optional; defaults to white text: #### The Alps - The Alps stretch across eight countries: France, Switzerland, Italy, Monaco, Liechtenstein, Austria, Germany, and Slovenia, covering about 1,200 kilometers (750 miles). - :end startTime: 9 @@ -137,7 +135,6 @@ With the graphics kit, you'll likely get your text and prop values from an Archi position: bottom center backgroundColour: rgba(0, 0, 0, 0.8) text: Mont Blanc, standing at 4,809 meters (15,777 feet), is the highest peak in the Alps and Western Europe, though there's ongoing debate between France and Italy about exactly where the summit lies. - :end startTime: 16 @@ -146,9 +143,7 @@ With the graphics kit, you'll likely get your text and prop values from an Archi position: bottom center backgroundColour: rgba(0, 0, 0, 0.8) text: #### History - The Alps were formed around **65 million years** ago when the African and Eurasian tectonic plates collided, pushing the land upward.Over 14 million people live in the Alpine region, with tourism supporting approximately 120 million visitors annually. - :end [] [] @@ -392,14 +387,176 @@ The `ScrollyVideo` component can be used inside the [ScrollerBase](?path=/story/ For advanced use cases such as looping a particular section of the video, or jumping to a specific time in the video, you can bind `scrollyVideo` prop and take benefits of methods such as `setVideoPercentage` or bindable methods such as `onReady` and `onChange`. This allows for fine-grained control over the video playback and interaction with the scroll position. -[Demo](?path=/story/components-graphics-scrollyvideo--advanced) - ```js scrollyVideo.setVideoPercentage(0.5, { - jump: false, - transitionSpeed: 12, - easing: d3.easeLinear, + jump: true, }); ``` -This will set the video to 50% progress, with a smooth transition at a playback rate of 12, using a linear easing function. +This will seek the video to 50% progress at a single instant. Setting `jump` to `false` will make smooth transition to the provided progress value. + +[Demo](?path=/story/components-graphics-scrollyvideo--advanced) + +```svelte + + + + {#snippet backgroundSnippet()} + + +
+

ScrollerBase progress: {progress.toPrecision(2)}

+ +
+ {/snippet} + {#snippet foregroundSnippet()} + +
+

Step 1

+
+
+

Step 2

+
+
+

Step 3

+
+ {/snippet} +
+ + +``` diff --git a/src/components/ScrollyVideo/ScrollyVideo.stories.svelte b/src/components/ScrollyVideo/ScrollyVideo.stories.svelte index 275280f1..aea00975 100644 --- a/src/components/ScrollyVideo/ScrollyVideo.stories.svelte +++ b/src/components/ScrollyVideo/ScrollyVideo.stories.svelte @@ -8,9 +8,6 @@ const { Story } = defineMeta({ title: 'Components/Graphics/ScrollyVideo', component: ScrollyVideo, - parameters: { - docsTools: { remount: true }, - }, argTypes: { autoplay: { control: 'boolean', diff --git a/src/components/ScrollyVideo/demo/AdvancedUsecases.svelte b/src/components/ScrollyVideo/demo/AdvancedUsecases.svelte index 89543794..2f090285 100644 --- a/src/components/ScrollyVideo/demo/AdvancedUsecases.svelte +++ b/src/components/ScrollyVideo/demo/AdvancedUsecases.svelte @@ -1,5 +1,157 @@ -TKTK + + {#snippet backgroundSnippet()} + +
+

ScrollerBase progress: {progress.toPrecision(2)}

+ +
+ {/snippet} + {#snippet foregroundSnippet()} + +
+

Step 1

+
+
+

Step 2

+
+
+

Step 3

+
+ {/snippet} +
+ + diff --git a/src/components/ScrollyVideo/videos/_tennis.mp4 b/src/components/ScrollyVideo/videos/_tennis.mp4 new file mode 100644 index 00000000..edefdeef Binary files /dev/null and b/src/components/ScrollyVideo/videos/_tennis.mp4 differ diff --git a/src/components/ScrollyVideo/videos/tennis.mp4 b/src/components/ScrollyVideo/videos/tennis.mp4 new file mode 100644 index 00000000..688cb4ee Binary files /dev/null and b/src/components/ScrollyVideo/videos/tennis.mp4 differ