packages/docs/docs/transitions/use-transition-progress.mdx
A hook that can be used inside a child of a <TransitionSeries.Sequence> to get the progress of the transition to directly manipulate the objects inside the scene.
It is meant to be used together with the none() presentation, but can be used with any other presentation.
import { useTransitionProgress } from "@remotion/transitions";
import { linearTiming, TransitionSeries } from "@remotion/transitions";
import { none } from "@remotion/transitions/none";
const A: React.FC = () => {
const progress = useTransitionProgress();
console.log(progress.entering); // Always `1`
console.log(progress.exiting); // Going from 0 to 1
console.log(progress.isInTransitionSeries); // `true`
return <div>A</div>;
};
const B: React.FC = () => {
const progress = useTransitionProgress();
console.log(progress.entering); // Going from 0 to 1
console.log(progress.exiting); // Always `0`
console.log(progress.isInTransitionSeries); // `true`
return <div>B</div>;
};
const C: React.FC = () => {
const progress = useTransitionProgress();
console.log(progress.entering); // Always `1`
console.log(progress.exiting); // Always `0`
console.log(progress.isInTransitionSeries); // `false`
return <div>C</div>;
};
const Transition: React.FC = () => {
return (
<>
<TransitionSeries>
<TransitionSeries.Sequence durationInFrames={40}>
<A />
</TransitionSeries.Sequence>
<TransitionSeries.Transition
presentation={none()}
timing={linearTiming({ durationInFrames: 30 })}
/>
<TransitionSeries.Sequence durationInFrames={60}>
<B />
</TransitionSeries.Sequence>
</TransitionSeries>
<C />
</>
);
};
A React hook that returns an object with the following properties:
enteringThe progress of the entering scene. If not inside a <TransitionSeries.Sequence>, it will always be 1.
exitingThe progress of the exiting scene. If not inside a <TransitionSeries.Sequence>, it will always be 0.
isInTransitionSeriesWhether the current scene is inside a <TransitionSeries.Sequence>.