🎥 Make videos programmatically with React
feat: add postmounting support to Sequence and SequenceContext types
Shankhadeep Dey680dd3e3c3f8
diff --git a/packages/core/src/Sequence.tsx b/packages/core/src/Sequence.tsxindex 432a99fc70..505e0228c8 100644--- a/packages/core/src/Sequence.tsx+++ b/packages/core/src/Sequence.tsx@@ -28,8 +28,10 @@ import {useCurrentFrame} from './use-current-frame';export type AbsoluteFillLayout = {layout?: 'absolute-fill';premountFor?: number;+ postmountFor?: number;style?: React.CSSProperties;styleWhilePremounted?: React.CSSProperties;+ styleWhilePostmounted?: React.CSSProperties;className?: string;};@@ -54,6 +56,10 @@ export type SequencePropsWithoutDuration = {* @deprecated For internal use only.*/readonly _remotionInternalPremountDisplay?: number | null;+ /**+ * @deprecated For internal use only.+ */+ readonly _remotionInternalPostmountDisplay?: number | null;/*** @deprecated For internal use only.*/@@ -62,6 +68,10 @@ export type SequencePropsWithoutDuration = {* @deprecated For internal use only.*/readonly _remotionInternalIsPremounting?: boolean;+ /**+ * @deprecated For internal use only.+ */+ readonly _remotionInternalIsPostmounting?: boolean;} & LayoutAndStyle;export type SequenceProps = {@@ -83,6 +93,7 @@ const RegularSequenceRefForwardingFunction: React.ForwardRefRenderFunction<_remotionInternalLoopDisplay: loopDisplay,_remotionInternalStack: stack,_remotionInternalPremountDisplay: premountDisplay,+ _remotionInternalPostmountDisplay: postmountDisplay,...other},ref,@@ -153,6 +164,14 @@ const RegularSequenceRefForwardingFunction: React.ForwardRefRenderFunction<);}, [other._remotionInternalIsPremounting, parentSequence?.premounting]);+ const postmounting = useMemo(() => {+ // || is intentional, ?? would not trigger on `false`+ return (+ parentSequence?.postmounting ||+ Boolean(other._remotionInternalIsPostmounting)+ );+ }, [other._remotionInternalIsPostmounting, parentSequence?.postmounting]);+const contextValue = useMemo((): SequenceContextType => {return {cumulatedFrom,@@ -163,6 +182,7 @@ const RegularSequenceRefForwardingFunction: React.ForwardRefRenderFunction<height: height ?? parentSequence?.height ?? null,width: width ?? parentSequence?.width ?? null,premounting,+ postmounting,};}, [cumulatedFrom,@@ -173,6 +193,7 @@ const RegularSequenceRefForwardingFunction: React.ForwardRefRenderFunction<height,width,premounting,+ postmounting,]);const timelineClipName = useMemo(() => {@@ -197,6 +218,7 @@ const RegularSequenceRefForwardingFunction: React.ForwardRefRenderFunction<loopDisplay,stack: stack ?? null,premountDisplay: premountDisplay ?? null,+ postmountDisplay: postmountDisplay ?? null,});return () => {unregisterSequence(id);@@ -217,6 +239,7 @@ const RegularSequenceRefForwardingFunction: React.ForwardRefRenderFunction<loopDisplay,stack,premountDisplay,+ postmountDisplay,]);// Ceil to support floatsdiff --git a/packages/core/src/SequenceContext.tsx b/packages/core/src/SequenceContext.tsxindex bfbb87e0e3..d2d79d3bd2 100644--- a/packages/core/src/SequenceContext.tsx+++ b/packages/core/src/SequenceContext.tsx@@ -11,4 +11,5 @@ export type SequenceContextType = {width: number | null;height: number | null;premounting: boolean;+ postmounting: boolean;};