Spaces:
Running
Running
File size: 1,217 Bytes
323961b 1ccdfb1 323961b 1ccdfb1 323961b 1ccdfb1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | import React from 'react';
import { useCurrentFrame, useVideoConfig } from 'remotion';
import { TransitionImplementationProps } from 'remotion-transition-series/lib/components/Transition';
export const CircularWipe: React.FC<
TransitionImplementationProps & { direction?: 'in' | 'out' }
> = ({
direction = 'out',
progress: inProgress,
exitingElement = null,
enteringElement = null,
}) => {
const { width: w, height: h } = useVideoConfig();
const radius = 0.5 * Math.sqrt(w * w + h * h);
const isOut = direction === 'out';
const progress = isOut ? inProgress : 1 - inProgress;
const polygon = `circle(${radius * progress}px)`;
return (
<>
<div
style={{
position: 'absolute',
left: 0,
top: 0,
right: 0,
bottom: 0,
}}
>
{isOut ? exitingElement : enteringElement}
</div>
<div
style={{
position: 'absolute',
left: 0,
top: 0,
right: 0,
bottom: 0,
clipPath: polygon,
}}
>
{isOut ? enteringElement : exitingElement}
</div>
</>
);
}; |