Skip to content

🎥 Make videos programmatically with React

Elements: Separate placement styles from root animations

Jonny Burger3fb6eb790a58
diff --git a/packages/docs/elements/commerce/product-collection/product-collection.tsx b/packages/docs/elements/commerce/product-collection/product-collection.tsx
index 368b2f09ef..a1b6e20fdd 100644
--- a/packages/docs/elements/commerce/product-collection/product-collection.tsx
+++ b/packages/docs/elements/commerce/product-collection/product-collection.tsx
@@ -1,6 +1,7 @@
import {loadFont} from '@remotion/google-fonts/Inter';
import React from 'react';
import {
+ AbsoluteFill,
Easing,
Img,
Interactive,
@@ -151,9 +152,7 @@ const ProductCard: React.FC<ProductCardProps> = ({count, index, label}) => {
);
};
-const ProductCollectionInner: React.FC<InteractiveTransformProps> = ({
- style,
-}) => {
+const ProductCollectionAnimation: React.FC = () => {
const frame = useCurrentFrame();
const {durationInFrames} = useVideoConfig();
@@ -205,7 +204,6 @@ const ProductCollectionInner: React.FC<InteractiveTransformProps> = ({
),
width: 900,
willChange: 'transform, opacity',
- ...style,
}}
>
<ProductCard count={3} index={0} label="A" />
@@ -215,6 +213,16 @@ const ProductCollectionInner: React.FC<InteractiveTransformProps> = ({
);
};
+const ProductCollectionInner: React.FC<InteractiveTransformProps> = ({
+ style,
+}) => {
+ return (
+ <AbsoluteFill style={style} showInTimeline={false}>
+ <ProductCollectionAnimation />
+ </AbsoluteFill>
+ );
+};
+
export const ProductCollection = Interactive.withSchema({
Component: ProductCollectionInner,
componentName: '<ProductCollection>',
diff --git a/packages/docs/elements/storytelling/polaroid-pictures/polaroid-pictures.tsx b/packages/docs/elements/storytelling/polaroid-pictures/polaroid-pictures.tsx
index 890da69278..b8af42e01e 100644
--- a/packages/docs/elements/storytelling/polaroid-pictures/polaroid-pictures.tsx
+++ b/packages/docs/elements/storytelling/polaroid-pictures/polaroid-pictures.tsx
@@ -1,6 +1,7 @@
import {fontFamily, loadFont} from '@remotion/google-fonts/Caveat';
import React from 'react';
import {
+ AbsoluteFill,
Easing,
Img,
Interactive,
@@ -15,18 +16,15 @@ loadFont('normal', {
subsets: ['latin'],
});
-const PolaroidPicturesInner: React.FC<InteractiveTransformProps> = ({
- style,
-}) => {
+const PolaroidPicturesAnimation: React.FC = () => {
const frame = useCurrentFrame();
const {durationInFrames} = useVideoConfig();
return (
- <div
+ <AbsoluteFill
+ showInTimeline={false}
style={{
color: '#2d2620',
- height: 640,
- position: 'relative',
scale: interpolate(frame, [58, durationInFrames - 32], [1, 1.035], {
easing: Easing.inOut(Easing.quad),
extrapolateLeft: 'clamp',
@@ -43,9 +41,7 @@ const PolaroidPicturesInner: React.FC<InteractiveTransformProps> = ({
extrapolateRight: 'clamp',
},
),
- width: 1480,
willChange: 'transform',
- ...style,
}}
>
<Interactive.Div
@@ -502,7 +498,17 @@ const PolaroidPicturesInner: React.FC<InteractiveTransformProps> = ({
scene C
</Interactive.Div>
</Interactive.Div>
- </div>
+ </AbsoluteFill>
+ );
+};
+
+const PolaroidPicturesInner: React.FC<InteractiveTransformProps> = ({
+ style,
+}) => {
+ return (
+ <AbsoluteFill style={style} showInTimeline={false}>
+ <PolaroidPicturesAnimation />
+ </AbsoluteFill>
);
};