From e897778dccfa6801261a635a633ff3d7f852dadd Mon Sep 17 00:00:00 2001 From: Sudev Kiyada Date: Tue, 3 Jun 2025 19:16:29 +0530 Subject: [PATCH] cleanup --- src/components/ScrollyVideo/ScrollyVideo.mdx | 90 +++++++++++++++++++- 1 file changed, 87 insertions(+), 3 deletions(-) diff --git a/src/components/ScrollyVideo/ScrollyVideo.mdx b/src/components/ScrollyVideo/ScrollyVideo.mdx index 78006058..b6eb85af 100644 --- a/src/components/ScrollyVideo/ScrollyVideo.mdx +++ b/src/components/ScrollyVideo/ScrollyVideo.mdx @@ -60,7 +60,7 @@ It can also be used to display multiple different videos based on the viewport w {#if width < 600} ``` +## Time based Foregrounds + +The `ScrollyVideo` component can also be used to display different foregrounds based on the current time in the video. This is useful for creating interactive experiences where the content changes as the video progresses. To throw off some ideas, one could add `Headline`, `GraphicBlock`, `FeaturePhoto` or any other component to the foreground based on the current time in the video. This can be achieved by adding `Foreground` components, along with their **startTime** and **endTime**, as a child to the main `ScrollyVideo` component. + +[Demo](?path=/story/components-graphics-scrollyvideo--time-based-foregrounds) + +```svelte + + + + +{#snippet ScrollForeground()} + + + + + + + + + + + + + + + + + + + + + + + +{/snippet} + +{#snippet ScrollVideo(height: string, VideoSrc: string)} + + {@render ScrollForeground()} + +{/snippet} + +{#if width < 600} + {@render ScrollVideo('800svh', `${assets}/videos/sm.mp4`)} +{:else if width < 1200} + {@render ScrollVideo('800svh', `${assets}/videos/md.mp4`)} +{:else} + {@render ScrollVideo('800svh', `${assets}/videos/lg.mp4`)} +{/if} + + +``` + ## Advanced usecases 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.