🎥 Make videos programmatically with React
Elements: Use component duration for product collection
Jonny Burgerc9991e7eaff3
diff --git a/packages/docs/elements/commerce/product-collection/product-collection.tsx b/packages/docs/elements/commerce/product-collection/product-collection.tsxindex eb480f6d94..368b2f09ef 100644--- a/packages/docs/elements/commerce/product-collection/product-collection.tsx+++ b/packages/docs/elements/commerce/product-collection/product-collection.tsx@@ -6,6 +6,7 @@ import {Interactive,interpolate,useCurrentFrame,+ useVideoConfig,type InteractiveTransformProps,} from 'remotion';@@ -14,8 +15,6 @@ loadFont('normal', {weights: ['500', '600', '700'],});-export const productCollectionDurationInFrames = 150;-type ProductCardProps = {readonly count: number;readonly index: number;@@ -24,10 +23,11 @@ type ProductCardProps = {const ProductCard: React.FC<ProductCardProps> = ({count, index, label}) => {const frame = useCurrentFrame();+ const {durationInFrames} = useVideoConfig();const lastProductIndex = Math.max(0, count - 1);const rawScrollPosition = interpolate(frame,- [24, productCollectionDurationInFrames - 28],+ [24, durationInFrames - 28],[0, lastProductIndex],{extrapolateLeft: 'clamp',@@ -155,6 +155,7 @@ const ProductCollectionInner: React.FC<InteractiveTransformProps> = ({style,}) => {const frame = useCurrentFrame();+ const {durationInFrames} = useVideoConfig();return (<Interactive.Div@@ -169,12 +170,7 @@ const ProductCollectionInner: React.FC<InteractiveTransformProps> = ({left: 60,opacity: interpolate(frame,- [- 0,- 10,- productCollectionDurationInFrames - 8,- productCollectionDurationInFrames - 1,- ],+ [0, 10, durationInFrames - 8, durationInFrames - 1],[0, 1, 1, 0],{easing: Easing.bezier(0.16, 1, 0.3, 1),@@ -186,12 +182,7 @@ const ProductCollectionInner: React.FC<InteractiveTransformProps> = ({position: 'absolute',scale: interpolate(frame,- [- 0,- 16,- productCollectionDurationInFrames - 8,- productCollectionDurationInFrames - 1,- ],+ [0, 16, durationInFrames - 8, durationInFrames - 1],[0.97, 1, 1, 0.98],{easing: Easing.bezier(0.16, 1, 0.3, 1),@@ -204,12 +195,7 @@ const ProductCollectionInner: React.FC<InteractiveTransformProps> = ({transform: 'perspective(100px)',translate: interpolate(frame,- [- 0,- 16,- productCollectionDurationInFrames - 8,- productCollectionDurationInFrames - 1,- ],+ [0, 16, durationInFrames - 8, durationInFrames - 1],['0px 30px', '0px 0px', '0px 0px', '0px -20px'],{easing: Easing.bezier(0.16, 1, 0.3, 1),diff --git a/packages/docs/src/components/Elements/element-definitions.ts b/packages/docs/src/components/Elements/element-definitions.tsindex 76bc84fff1..4e536790f8 100644--- a/packages/docs/src/components/Elements/element-definitions.ts+++ b/packages/docs/src/components/Elements/element-definitions.ts@@ -30,10 +30,7 @@ import {roundedCaptionsInitialProps} from '../../../elements/captions/rounded-caimport {RoundedCaptions} from '../../../elements/captions/rounded-captions/rounded-captions';import {wordHighlightCaptionsInitialProps} from '../../../elements/captions/word-highlight-captions/initial-props';import {WordHighlightCaptions} from '../../../elements/captions/word-highlight-captions/word-highlight-captions';-import {- ProductCollection,- productCollectionDurationInFrames,-} from '../../../elements/commerce/product-collection/product-collection';+import {ProductCollection} from '../../../elements/commerce/product-collection/product-collection';import {ProductDiscountCallout} from '../../../elements/commerce/product-discount-callout/product-discount-callout';import {Shine} from '../../../elements/commerce/shine/shine';import {Tear} from '../../../elements/commerce/tear/tear';@@ -538,7 +535,7 @@ const elementImplementations = [contributors: [],description: 'Three cards which each take center once.',dependencies: [{name: '@remotion/google-fonts', version: null}],- durationInFrames: productCollectionDurationInFrames,+ durationInFrames: 150,elementHeight: 1020,elementWidth: 1020,fps: 30,