Freeze portions of a sequence
With the following snippet, two portions of a sequence are frozen and resumed afterwards from the point they were paused.
tsximportReact , {useMemo } from'react';import {Freeze ,Sequence ,useCurrentFrame } from'remotion';exportconstCounter :React .FC = () => {return (<div className ="flex h-full justify-center items-center text-6xl">{useCurrentFrame ()}</div >);};constFREEZES = [{frame : 0,durationInFrames : 25,},{frame : 30,durationInFrames : 50,},];constgetFreezes = () => {letsummedUpFreezes =0;constfreezeFrames = [];for (constfreeze ofFREEZES ) {freezeFrames .push ({start :summedUpFreezes +freeze .frame ,durationInFrames :freeze .durationInFrames ,from :summedUpFreezes ,frame :freeze .frame ,});summedUpFreezes +=freeze .durationInFrames ;}returnfreezeFrames ;};exportconstFreezePortion :React .FC = () => {constfreezes =useMemo (() => {returngetFreezes ();}, []);constframe =useCurrentFrame ();constnextFreeze =freezes .find ((freeze ) =>frame <freeze .start +freeze .durationInFrames ,);constactiveFreeze =freezes .find ((freeze ) =>frame >=freeze .start &&frame <freeze .start +freeze .durationInFrames ,);constfrom =useMemo (() => {if (activeFreeze ) {return0;}if (nextFreeze ) {returnnextFreeze .from ;}return (freezes [freezes .length -1].from +freezes [freezes .length -1].durationInFrames );}, [activeFreeze ,freezes ,nextFreeze ]);return (<Freeze frame ={activeFreeze ?activeFreeze .frame :0}active ={Boolean (activeFreeze )}><Sequence layout ="none"from ={from }><Counter /></Sequence ></Freeze >);};