🎥 Make videos programmatically with React
Elements: Keep product collection timing fixed
Igor Samokhovets122a1847d8c3
diff --git a/packages/docs/elements/commerce/product-collection/product-collection.tsx b/packages/docs/elements/commerce/product-collection/product-collection.tsxindex 4df652705f..9b7b6d0e5c 100644--- a/packages/docs/elements/commerce/product-collection/product-collection.tsx+++ b/packages/docs/elements/commerce/product-collection/product-collection.tsx@@ -7,7 +7,6 @@ import {Sequence,interpolate,useCurrentFrame,- useVideoConfig,type InteractiveBaseProps,type InteractiveTransformProps,type InteractivitySchema,@@ -19,6 +18,8 @@ loadFont('normal', {weights: ['500', '600', '700'],});+export const productCollectionDurationInFrames = 150;+type ProductCardProps = InteractiveBaseProps &Omit<InteractiveTransformProps, 'style'> & {readonly count: number;@@ -97,11 +98,10 @@ const ProductCardInner = forwardRef<) => {const outlineRef = useRef<HTMLDivElement>(null);const frame = useCurrentFrame();- const {durationInFrames} = useVideoConfig();const lastProductIndex = Math.max(0, count - 1);const rawScrollPosition = interpolate(frame,- [24, durationInFrames - 28],+ [24, productCollectionDurationInFrames - 28],[0, lastProductIndex],{extrapolateLeft: 'clamp',@@ -222,7 +222,7 @@ const ProductCardInner = forwardRef<objectPosition: '50% 50%',scale: interpolate(frame,- [0, durationInFrames - 1],+ [0, productCollectionDurationInFrames - 1],[1.06, 1.01],{easing: Easing.inOut(Easing.quad),@@ -355,7 +355,6 @@ const ProductCard = Interactive.withSchema({export const ProductCollection = () => {const frame = useCurrentFrame();- const {durationInFrames: collectionDurationInFrames} = useVideoConfig();return (<Interactive.Div@@ -373,8 +372,8 @@ export const ProductCollection = () => {[0,10,- collectionDurationInFrames - 8,- collectionDurationInFrames - 1,+ productCollectionDurationInFrames - 8,+ productCollectionDurationInFrames - 1,],[0, 1, 1, 0],{@@ -390,8 +389,8 @@ export const ProductCollection = () => {[0,16,- collectionDurationInFrames - 8,- collectionDurationInFrames - 1,+ productCollectionDurationInFrames - 8,+ productCollectionDurationInFrames - 1,],[0.97, 1, 1, 0.98],{@@ -408,8 +407,8 @@ export const ProductCollection = () => {[0,16,- collectionDurationInFrames - 8,- collectionDurationInFrames - 1,+ productCollectionDurationInFrames - 8,+ productCollectionDurationInFrames - 1,],['0px 30px', '0px 0px', '0px 0px', '0px -20px'],{diff --git a/packages/docs/src/components/Elements/element-definitions.ts b/packages/docs/src/components/Elements/element-definitions.tsindex 857ff6765a..5ac4f17581 100644--- a/packages/docs/src/components/Elements/element-definitions.ts+++ b/packages/docs/src/components/Elements/element-definitions.ts@@ -10,7 +10,10 @@ import {RotatingStarburst} from '../../../elements/backgrounds/rotating-starbursimport {MovingPillCaptions} from '../../../elements/captions/moving-pill-captions/moving-pill-captions';import {PoppingWordCaptions} from '../../../elements/captions/popping-word-captions/popping-word-captions';import {WordHighlightCaptions} from '../../../elements/captions/word-highlight-captions/word-highlight-captions';-import {ProductCollection} from '../../../elements/commerce/product-collection/product-collection';+import {+ ProductCollection,+ productCollectionDurationInFrames,+} from '../../../elements/commerce/product-collection/product-collection';import {ProductDiscountCallout} from '../../../elements/commerce/product-discount-callout/product-discount-callout';import {ProductOffer} from '../../../elements/commerce/product-offer/product-offer';import {HorizontalBarChart} from '../../../elements/data/horizontal-bar-chart/horizontal-bar-chart';@@ -431,7 +434,7 @@ const elementImplementations = {description:'An animated product carousel that adapts to changing catalog images, titles, prices, and promotions.',dependencies: [{name: '@remotion/google-fonts', version: null}],- durationInFrames: 150,+ durationInFrames: productCollectionDurationInFrames,elementHeight: 1020,elementWidth: 1020,fps: 30,