Skip to content

🎥 Make videos programmatically with React

Elements: Derive animation timing from component duration

Jonny Burger7e9161478770
diff --git a/packages/docs/elements/backgrounds/liquid-contours/liquid-contours.tsx b/packages/docs/elements/backgrounds/liquid-contours/liquid-contours.tsx
index ac09e8d9fd..1325b48d77 100644
--- a/packages/docs/elements/backgrounds/liquid-contours/liquid-contours.tsx
+++ b/packages/docs/elements/backgrounds/liquid-contours/liquid-contours.tsx
@@ -12,7 +12,7 @@ import {
const LiquidContoursInner: React.FC<InteractiveTransformProps> = ({style}) => {
const frame = useCurrentFrame();
- const {height, width} = useVideoConfig();
+ const {durationInFrames, height, width} = useVideoConfig();
return (
<AbsoluteFill style={style} showInTimeline={false}>
@@ -24,7 +24,7 @@ const LiquidContoursInner: React.FC<InteractiveTransformProps> = ({style}) => {
liquidContours({
firstColor: '#dff4ff',
secondColor: '#7cc6ff',
- phase: interpolate(frame, [0, 240], [3.23, 4.23]),
+ phase: interpolate(frame, [0, durationInFrames], [3.23, 4.23]),
}),
]}
/>
diff --git a/packages/docs/elements/backgrounds/paper-texture/paper-texture.tsx b/packages/docs/elements/backgrounds/paper-texture/paper-texture.tsx
index 5c72f47686..58fd1bf570 100644
--- a/packages/docs/elements/backgrounds/paper-texture/paper-texture.tsx
+++ b/packages/docs/elements/backgrounds/paper-texture/paper-texture.tsx
@@ -12,7 +12,7 @@ import {
const PaperTextureInner: React.FC<InteractiveTransformProps> = ({style}) => {
const frame = useCurrentFrame();
- const {height, width} = useVideoConfig();
+ const {durationInFrames, height, width} = useVideoConfig();
return (
<AbsoluteFill style={style} showInTimeline={false}>
@@ -24,7 +24,7 @@ const PaperTextureInner: React.FC<InteractiveTransformProps> = ({style}) => {
paper({
colorFront: 'white',
colorBack: 'white',
- seed: interpolate(frame, [0, 120], [0, 1000], {
+ seed: interpolate(frame, [0, durationInFrames], [0, 1000], {
extrapolateLeft: 'clamp',
extrapolateRight: 'clamp',
posterize: 30,
diff --git a/packages/docs/elements/commerce/product-collection/product-collection.tsx b/packages/docs/elements/commerce/product-collection/product-collection.tsx
index a1b6e20fdd..1c92221dbc 100644
--- a/packages/docs/elements/commerce/product-collection/product-collection.tsx
+++ b/packages/docs/elements/commerce/product-collection/product-collection.tsx
@@ -24,11 +24,11 @@ type ProductCardProps = {
const ProductCard: React.FC<ProductCardProps> = ({count, index, label}) => {
const frame = useCurrentFrame();
- const {durationInFrames} = useVideoConfig();
+ const {durationInFrames: cardDurationInFrames} = useVideoConfig();
const lastProductIndex = Math.max(0, count - 1);
const rawScrollPosition = interpolate(
frame,
- [24, durationInFrames - 28],
+ [24, cardDurationInFrames - 28],
[0, lastProductIndex],
{
extrapolateLeft: 'clamp',
diff --git a/packages/docs/elements/commerce/shine/shine.tsx b/packages/docs/elements/commerce/shine/shine.tsx
index 51940aac41..399ec4f6fe 100644
--- a/packages/docs/elements/commerce/shine/shine.tsx
+++ b/packages/docs/elements/commerce/shine/shine.tsx
@@ -8,11 +8,13 @@ import {
HtmlInCanvas,
interpolate,
useCurrentFrame,
+ useVideoConfig,
type InteractiveTransformProps,
} from 'remotion';
const ShineInner: React.FC<InteractiveTransformProps> = ({style}) => {
const frame = useCurrentFrame();
+ const {durationInFrames} = useVideoConfig();
return (
<AbsoluteFill style={style} showInTimeline={false}>
@@ -20,7 +22,7 @@ const ShineInner: React.FC<InteractiveTransformProps> = ({style}) => {
effects={[
scale({scale: 0.75}),
shine({
- progress: interpolate(frame, [0, 44], [0, 1], {
+ progress: interpolate(frame, [0, durationInFrames - 1], [0, 1], {
extrapolateLeft: 'clamp',
extrapolateRight: 'clamp',
}),
diff --git a/packages/docs/elements/data/number-counter/number-counter.tsx b/packages/docs/elements/data/number-counter/number-counter.tsx
index 2e58670027..7162334dd9 100644
--- a/packages/docs/elements/data/number-counter/number-counter.tsx
+++ b/packages/docs/elements/data/number-counter/number-counter.tsx
@@ -5,6 +5,7 @@ import {
Interactive,
interpolate,
useCurrentFrame,
+ useVideoConfig,
type InteractiveTransformProps,
} from 'remotion';
@@ -15,8 +16,9 @@ loadFont('normal', {
const NumberCounterInner: React.FC<InteractiveTransformProps> = ({style}) => {
const frame = useCurrentFrame();
+ const {durationInFrames} = useVideoConfig();
- const progress = interpolate(frame, [0, 90], [0, 1], {
+ const progress = interpolate(frame, [0, durationInFrames * 0.75], [0, 1], {
extrapolateLeft: 'clamp',
extrapolateRight: 'clamp',
easing: Easing.out(Easing.exp),
diff --git a/packages/docs/elements/layouts/slide-to-split-screen/slide-to-split-screen.tsx b/packages/docs/elements/layouts/slide-to-split-screen/slide-to-split-screen.tsx
index 67f3145ba0..41e96c8a0b 100644
--- a/packages/docs/elements/layouts/slide-to-split-screen/slide-to-split-screen.tsx
+++ b/packages/docs/elements/layouts/slide-to-split-screen/slide-to-split-screen.tsx
@@ -16,19 +16,24 @@ const SlideToSplitScreenInner: React.FC<InteractiveTransformProps> = ({
style,
}) => {
const frame = useCurrentFrame();
- const {height, width} = useVideoConfig();
+ const {durationInFrames, height, width} = useVideoConfig();
const bPanelWidth = width * 0.4;
const aPanelWidth = width - bPanelWidth - DIVIDER_WIDTH;
const aShift = (width - aPanelWidth) / 2;
- const splitProgress = interpolate(frame, [20, 52, 98, 130], [0, 1, 1, 0], {
- easing: [
- Easing.bezier(0.65, 0, 0.35, 1),
- Easing.linear,
- Easing.bezier(0.65, 0, 0.35, 1),
- ],
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- });
+ const splitProgress = interpolate(
+ frame,
+ [20, 52, durationInFrames - 52, durationInFrames - 20],
+ [0, 1, 1, 0],
+ {
+ easing: [
+ Easing.bezier(0.65, 0, 0.35, 1),
+ Easing.linear,
+ Easing.bezier(0.65, 0, 0.35, 1),
+ ],
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ },
+ );
return (
<AbsoluteFill
diff --git a/packages/docs/elements/maps/map-flyover/a-to-b-map-flyover.tsx b/packages/docs/elements/maps/map-flyover/a-to-b-map-flyover.tsx
index 15a99f683a..2ed073f473 100644
--- a/packages/docs/elements/maps/map-flyover/a-to-b-map-flyover.tsx
+++ b/packages/docs/elements/maps/map-flyover/a-to-b-map-flyover.tsx
@@ -280,7 +280,7 @@ const MapFlyoverContent: React.FC<MapFlyoverLayerProps> = ({
style,
}) => {
const frame = useCurrentFrame();
- const {height, width} = useVideoConfig();
+ const {durationInFrames, height, width} = useVideoConfig();
const {continueRender, delayRender} = useDelayRender();
const {delayPlayback} = useBufferState();
const mapContainerRef = useRef<HTMLDivElement>(null);
@@ -313,7 +313,7 @@ const MapFlyoverContent: React.FC<MapFlyoverLayerProps> = ({
[mapPlate, route],
);
const travelStart = 0;
- const travelEnd = 205;
+ const travelEnd = Math.max(1, durationInFrames - 80);
const travelProgress = interpolate(frame, [travelStart, travelEnd], [0, 1], {
easing: Easing.inOut(Easing.quad),
extrapolateLeft: 'clamp',
diff --git a/packages/docs/elements/maps/watercolor-map/watercolor-map.tsx b/packages/docs/elements/maps/watercolor-map/watercolor-map.tsx
index 0017e7e1d1..2d84eb373a 100644
--- a/packages/docs/elements/maps/watercolor-map/watercolor-map.tsx
+++ b/packages/docs/elements/maps/watercolor-map/watercolor-map.tsx
@@ -167,7 +167,7 @@ const WatercolorMapContent: React.FC<WatercolorMapProps> = ({
style,
}) => {
const frame = useCurrentFrame();
- const {fps, height, width} = useVideoConfig();
+ const {durationInFrames, fps, height, width} = useVideoConfig();
const zoom = getZoom(origin, destination);
const worldSize = TILE_SIZE * 2 ** zoom;
const projectedOrigin = projectCoordinates(origin, zoom);
@@ -182,7 +182,8 @@ const WatercolorMapContent: React.FC<WatercolorMapProps> = ({
destinationX += worldSize;
}
- const travelProgress = interpolate(frame, [40, 130], [0, 1], {
+ const travelEnd = Math.max(41, durationInFrames - 70);
+ const travelProgress = interpolate(frame, [40, travelEnd], [0, 1], {
easing: Easing.inOut(Easing.ease),
extrapolateLeft: 'clamp',
extrapolateRight: 'clamp',
@@ -221,13 +222,13 @@ const WatercolorMapContent: React.FC<WatercolorMapProps> = ({
});
const destinationMarkerScale = spring({
fps,
- frame: frame - 133,
+ frame: frame - travelEnd - 3,
config: {damping: 200},
durationInFrames: 20,
});
const destinationLabelOpacity = spring({
fps,
- frame: frame - 130,
+ frame: frame - travelEnd,
config: {damping: 200},
durationInFrames: 20,
});
diff --git a/packages/docs/elements/overlays/location-lower-third/location-lower-third.tsx b/packages/docs/elements/overlays/location-lower-third/location-lower-third.tsx
index 42cd816a86..f69bda77be 100644
--- a/packages/docs/elements/overlays/location-lower-third/location-lower-third.tsx
+++ b/packages/docs/elements/overlays/location-lower-third/location-lower-third.tsx
@@ -4,6 +4,7 @@ import {
Interactive,
interpolate,
useCurrentFrame,
+ useVideoConfig,
type InteractiveTransformProps,
} from 'remotion';
@@ -13,6 +14,7 @@ const LocationLowerThirdInner: React.FC<InteractiveTransformProps> = ({
style,
}) => {
const frame = useCurrentFrame();
+ const {durationInFrames} = useVideoConfig();
return (
<Interactive.Div
name="Container"
@@ -37,13 +39,18 @@ const LocationLowerThirdInner: React.FC<InteractiveTransformProps> = ({
height: 130,
overflow: 'visible',
filter: 'drop-shadow(0 6px 8px rgba(24, 24, 27, 0.14))',
- opacity: interpolate(frame, [0, 9, 108, 119], [0, 1, 1, 0], {
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- }),
+ opacity: interpolate(
+ frame,
+ [0, 9, durationInFrames - 12, durationInFrames - 1],
+ [0, 1, 1, 0],
+ {
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ },
+ ),
translate: interpolate(
frame,
- [0, 16, 106, 119],
+ [0, 16, durationInFrames - 14, durationInFrames - 1],
['0px -10px', '0px 0px', '0px 0px', '0px -8px'],
{
easing: Easing.out(Easing.cubic),
@@ -51,11 +58,16 @@ const LocationLowerThirdInner: React.FC<InteractiveTransformProps> = ({
extrapolateRight: 'clamp',
},
),
- scale: interpolate(frame, [0, 16, 106, 119], [0.88, 1, 1, 0.92], {
- easing: Easing.out(Easing.cubic),
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- }),
+ scale: interpolate(
+ frame,
+ [0, 16, durationInFrames - 14, durationInFrames - 1],
+ [0.88, 1, 1, 0.92],
+ {
+ easing: Easing.out(Easing.cubic),
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ },
+ ),
transformOrigin: '52px 126px',
}}
>
@@ -63,15 +75,20 @@ const LocationLowerThirdInner: React.FC<InteractiveTransformProps> = ({
d="M32 3C15.4 3 4 15.4 4 31C4 50.8 22.1 69.6 29.3 76.2C30.8 77.6 33.2 77.6 34.7 76.2C41.9 69.6 60 50.8 60 31C60 15.4 48.6 3 32 3Z"
pathLength="1"
fill="#2563eb"
- fillOpacity={interpolate(frame, [5, 18, 105, 114], [0, 1, 1, 0], {
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- })}
+ fillOpacity={interpolate(
+ frame,
+ [5, 18, durationInFrames - 15, durationInFrames - 6],
+ [0, 1, 1, 0],
+ {
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ },
+ )}
stroke="#2563eb"
strokeDasharray="1"
strokeDashoffset={interpolate(
frame,
- [0, 16, 105, 116],
+ [0, 16, durationInFrames - 15, durationInFrames - 4],
[1, 0, 0, 1],
{
easing: Easing.out(Easing.cubic),
@@ -86,11 +103,16 @@ const LocationLowerThirdInner: React.FC<InteractiveTransformProps> = ({
<circle
cx="32"
cy="30"
- r={interpolate(frame, [10, 21, 102, 112], [0, 9, 9, 0], {
- easing: Easing.out(Easing.cubic),
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- })}
+ r={interpolate(
+ frame,
+ [10, 21, durationInFrames - 18, durationInFrames - 8],
+ [0, 9, 9, 0],
+ {
+ easing: Easing.out(Easing.cubic),
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ },
+ )}
fill="#eff6ff"
/>
</Interactive.Svg>
@@ -115,30 +137,35 @@ const LocationLowerThirdInner: React.FC<InteractiveTransformProps> = ({
}}
>
<Interactive.Div
- cropRight={interpolate(frame, [14, 38, 88, 108], [1, 0, 0, 1], {
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
+ cropRight={interpolate(
+ frame,
+ [14, 38, durationInFrames - 32, durationInFrames - 12],
+ [1, 0, 0, 1],
+ {
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
- easing: [
- Easing.spring({
- damping: 200,
- mass: 1,
- stiffness: 100,
- allowTail: true,
- durationRestThreshold: 0.02,
- overshootClamping: false,
- }),
- Easing.linear,
- Easing.spring({
- damping: 200,
- mass: 1,
- stiffness: 100,
- allowTail: true,
- durationRestThreshold: 0.02,
- overshootClamping: false,
- }),
- ],
- })}
+ easing: [
+ Easing.spring({
+ damping: 200,
+ mass: 1,
+ stiffness: 100,
+ allowTail: true,
+ durationRestThreshold: 0.02,
+ overshootClamping: false,
+ }),
+ Easing.linear,
+ Easing.spring({
+ damping: 200,
+ mass: 1,
+ stiffness: 100,
+ allowTail: true,
+ durationRestThreshold: 0.02,
+ overshootClamping: false,
+ }),
+ ],
+ },
+ )}
name="Location"
dir="auto"
style={{
@@ -149,10 +176,15 @@ const LocationLowerThirdInner: React.FC<InteractiveTransformProps> = ({
letterSpacing: -1,
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
- opacity: interpolate(frame, [14, 22, 98, 110], [0, 1, 1, 0], {
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- }),
+ opacity: interpolate(
+ frame,
+ [14, 22, durationInFrames - 22, durationInFrames - 10],
+ [0, 1, 1, 0],
+ {
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ },
+ ),
}}
>
{location}
diff --git a/packages/docs/elements/overlays/name-lower-third/name-lower-third.tsx b/packages/docs/elements/overlays/name-lower-third/name-lower-third.tsx
index 89bd6937d7..d66b7e4da5 100644
--- a/packages/docs/elements/overlays/name-lower-third/name-lower-third.tsx
+++ b/packages/docs/elements/overlays/name-lower-third/name-lower-third.tsx
@@ -5,6 +5,7 @@ import {
Interactive,
interpolate,
useCurrentFrame,
+ useVideoConfig,
type InteractiveTransformProps,
} from 'remotion';
@@ -15,6 +16,7 @@ loadFont('normal', {
const NameLowerThirdInner: React.FC<InteractiveTransformProps> = ({style}) => {
const frame = useCurrentFrame();
+ const {durationInFrames} = useVideoConfig();
return (
<Interactive.Div
@@ -32,15 +34,20 @@ const NameLowerThirdInner: React.FC<InteractiveTransformProps> = ({style}) => {
}}
>
<Interactive.Div
- cropRight={interpolate(frame, [0, 20, 96, 116], [1, 0, 0, 1], {
- easing: [
- Easing.bezier(0.65, 0, 0.35, 1),
- Easing.linear,
- Easing.bezier(0.65, 0, 0.35, 1),
- ],
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- })}
+ cropRight={interpolate(
+ frame,
+ [0, 20, durationInFrames - 24, durationInFrames - 4],
+ [1, 0, 0, 1],
+ {
+ easing: [
+ Easing.bezier(0.65, 0, 0.35, 1),
+ Easing.linear,
+ Easing.bezier(0.65, 0, 0.35, 1),
+ ],
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ },
+ )}
name="Name bar"
style={{
display: 'flex',
@@ -61,15 +68,20 @@ const NameLowerThirdInner: React.FC<InteractiveTransformProps> = ({style}) => {
Alex Morgan
</Interactive.Div>
<Interactive.Div
- cropRight={interpolate(frame, [4, 24, 92, 112], [1, 0, 0, 1], {
- easing: [
- Easing.bezier(0.65, 0, 0.35, 1),
- Easing.linear,
- Easing.bezier(0.65, 0, 0.35, 1),
- ],
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- })}
+ cropRight={interpolate(
+ frame,
+ [4, 24, durationInFrames - 28, durationInFrames - 8],
+ [1, 0, 0, 1],
+ {
+ easing: [
+ Easing.bezier(0.65, 0, 0.35, 1),
+ Easing.linear,
+ Easing.bezier(0.65, 0, 0.35, 1),
+ ],
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ },
+ )}
name="Title bar"
style={{
display: 'flex',
diff --git a/packages/docs/elements/text/news-article-highlight/news-article-highlight.tsx b/packages/docs/elements/text/news-article-highlight/news-article-highlight.tsx
index 59a79cda00..da735b65b8 100644
--- a/packages/docs/elements/text/news-article-highlight/news-article-highlight.tsx
+++ b/packages/docs/elements/text/news-article-highlight/news-article-highlight.tsx
@@ -6,6 +6,7 @@ import {
Interactive,
interpolate,
useCurrentFrame,
+ useVideoConfig,
type InteractiveTransformProps,
} from 'remotion';
@@ -44,6 +45,7 @@ const NewsArticleHighlightInner: React.FC<InteractiveTransformProps> = ({
style,
}) => {
const frame = useCurrentFrame();
+ const {durationInFrames} = useVideoConfig();
const firstHighlightProgress = getHighlightProgress(frame, 0);
const secondHighlightProgress = getHighlightProgress(frame, 1);
@@ -62,11 +64,16 @@ const NewsArticleHighlightInner: React.FC<InteractiveTransformProps> = ({
name="Container"
style={{
height: 458,
- opacity: interpolate(frame, [125, 149], [1, 0], {
- easing: Easing.in(Easing.cubic),
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- }),
+ opacity: interpolate(
+ frame,
+ [durationInFrames - 25, durationInFrames - 1],
+ [1, 0],
+ {
+ easing: Easing.in(Easing.cubic),
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ },
+ ),
width: 1420,
willChange: 'opacity',
}}
diff --git a/packages/docs/elements/text/spinning-text-wheel/spinning-text-wheel.tsx b/packages/docs/elements/text/spinning-text-wheel/spinning-text-wheel.tsx
index ca2883e7c2..6c86ebaaf9 100644
--- a/packages/docs/elements/text/spinning-text-wheel/spinning-text-wheel.tsx
+++ b/packages/docs/elements/text/spinning-text-wheel/spinning-text-wheel.tsx
@@ -53,7 +53,7 @@ const SpinningTextWheelInner: React.FC<SpinningTextWheelProps> = ({
style,
}) => {
const frame = useCurrentFrame();
- const {fps} = useVideoConfig();
+ const {durationInFrames, fps} = useVideoConfig();
const values = items
.split('\n')
.map((item) => item.trim())
@@ -66,7 +66,7 @@ const SpinningTextWheelInner: React.FC<SpinningTextWheelProps> = ({
damping: 200,
stiffness: 200,
},
- durationInFrames: 90,
+ durationInFrames: durationInFrames * 0.75,
durationRestThreshold: 0.0001,
});
const rotation = interpolate(progress, [0, 1], [1, 0]);
diff --git a/packages/docs/elements/youtube/youtube-comment-highlight/youtube-comment-highlight.tsx b/packages/docs/elements/youtube/youtube-comment-highlight/youtube-comment-highlight.tsx
index d234f56ed6..708d99b93f 100644
--- a/packages/docs/elements/youtube/youtube-comment-highlight/youtube-comment-highlight.tsx
+++ b/packages/docs/elements/youtube/youtube-comment-highlight/youtube-comment-highlight.tsx
@@ -6,6 +6,7 @@ import {
Interactive,
interpolate,
useCurrentFrame,
+ useVideoConfig,
type InteractiveTransformProps,
} from 'remotion';
@@ -18,6 +19,7 @@ const YouTubeCommentHighlightInner: React.FC<InteractiveTransformProps> = ({
style,
}) => {
const frame = useCurrentFrame();
+ const {durationInFrames} = useVideoConfig();
return (
<div
@@ -50,7 +52,7 @@ const YouTubeCommentHighlightInner: React.FC<InteractiveTransformProps> = ({
transformOrigin: '50% 50%',
translate: interpolate(
frame,
- [0, 48, 131, 179],
+ [0, 48, durationInFrames - 49, durationInFrames - 1],
['0px 760px', '0px 0px', '0px 0px', '0px 760px'],
{
easing: [
diff --git a/packages/docs/elements/youtube/youtube-subscribe-nudge/youtube-subscribe-nudge.tsx b/packages/docs/elements/youtube/youtube-subscribe-nudge/youtube-subscribe-nudge.tsx
index 7fc1e54aeb..09ae160109 100644
--- a/packages/docs/elements/youtube/youtube-subscribe-nudge/youtube-subscribe-nudge.tsx
+++ b/packages/docs/elements/youtube/youtube-subscribe-nudge/youtube-subscribe-nudge.tsx
@@ -8,6 +8,7 @@ import {
Interactive,
interpolate,
useCurrentFrame,
+ useVideoConfig,
type InteractiveTransformProps,
} from 'remotion';
@@ -29,6 +30,7 @@ const YouTubeSubscribeNudgeInner: React.FC<
style,
}) => {
const frame = useCurrentFrame();
+ const {durationInFrames} = useVideoConfig();
return (
<div
@@ -58,30 +60,40 @@ const YouTubeSubscribeNudgeInner: React.FC<
<div
style={{
height: 240,
- opacity: interpolate(frame, [0, 24, 104, 119], [0, 1, 1, 0], {
- easing: [
- Easing.bezier(0.65, 0, 0.35, 1),
- Easing.linear,
- Easing.bezier(0.7, 0, 0.84, 0),
- ],
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- }),
+ opacity: interpolate(
+ frame,
+ [0, 24, durationInFrames - 16, durationInFrames - 1],
+ [0, 1, 1, 0],
+ {
+ easing: [
+ Easing.bezier(0.65, 0, 0.35, 1),
+ Easing.linear,
+ Easing.bezier(0.7, 0, 0.84, 0),
+ ],
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ },
+ ),
position: 'relative',
- scale: interpolate(frame, [0, 24, 104, 119], [0.98, 1, 1, 0.97], {
- easing: [
- Easing.bezier(0.65, 0, 0.35, 1),
- Easing.linear,
- Easing.bezier(0.7, 0, 0.84, 0),
- ],
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- output: 'perceptual-scale',
- }),
+ scale: interpolate(
+ frame,
+ [0, 24, durationInFrames - 16, durationInFrames - 1],
+ [0.98, 1, 1, 0.97],
+ {
+ easing: [
+ Easing.bezier(0.65, 0, 0.35, 1),
+ Easing.linear,
+ Easing.bezier(0.7, 0, 0.84, 0),
+ ],
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ output: 'perceptual-scale',
+ },
+ ),
transformOrigin: '50% 50%',
translate: interpolate(
frame,
- [0, 24, 104, 119],
+ [0, 24, durationInFrames - 16, durationInFrames - 1],
['0px 14px', '0px 0px', '0px 0px', '0px 20px'],
{
easing: [