Created
August 15, 2023 07:39
-
-
Save JonnyBurger/f997628e61d6077ad27961d86137b3d9 to your computer and use it in GitHub Desktop.
Remotion Page Transition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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