Skip to content

Instantly share code, notes, and snippets.

@JonnyBurger
Created August 15, 2023 07:39
Show Gist options
  • Save JonnyBurger/f997628e61d6077ad27961d86137b3d9 to your computer and use it in GitHub Desktop.
Save JonnyBurger/f997628e61d6077ad27961d86137b3d9 to your computer and use it in GitHub Desktop.
Remotion Page Transition
import React from 'react';
import {
AbsoluteFill,
interpolate,
Sequence,
spring,
useCurrentFrame,
useVideoConfig,
} from 'remotion';
export const PageTransition: React.FC = () => {
const transitionAt = 50;
const {fps, width} = useVideoConfig();
const frame = useCurrentFrame();
const transition = spring({
fps,
frame,
delay: transitionAt,
durationInFrames: 30,
config: {
damping: 200,
},
});
const left = interpolate(transition, [0, 1], [width, 0]);
return (
<AbsoluteFill>
<AbsoluteFill
style={{
backgroundColor: 'red',
}}
>
Page 1
</AbsoluteFill>
<Sequence
style={{
backgroundColor: 'yellow',
transform: `translateX(${left}px)`,
}}
from={transitionAt}
>
Page 2
</Sequence>
</AbsoluteFill>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment