Skip to content

🎥 Make videos programmatically with React

sequences who accept width or height

Jonny Burgerb49bd87c3dff
diff --git a/packages/core/src/Sequence.tsx b/packages/core/src/Sequence.tsx
index ea6da06a8f..d2e8bff7bd 100644
--- a/packages/core/src/Sequence.tsx
+++ b/packages/core/src/Sequence.tsx
@@ -33,6 +33,8 @@ export type LayoutAndStyle =
export type SequencePropsWithoutDuration = {
children: React.ReactNode;
+ width?: number;
+ height?: number;
from?: number;
name?: string;
/**
@@ -58,6 +60,8 @@ const SequenceRefForwardingFunction: React.ForwardRefRenderFunction<
durationInFrames = Infinity,
children,
name,
+ height,
+ width,
showInTimeline = true,
loopDisplay,
...other
@@ -128,13 +132,17 @@ const SequenceRefForwardingFunction: React.ForwardRefRenderFunction<
durationInFrames: actualDurationInFrames,
parentFrom: parentSequence?.relativeFrom ?? 0,
id,
+ height: height ?? parentSequence?.height ?? null,
+ width: width ?? parentSequence?.width ?? null,
};
}, [
cumulatedFrom,
from,
actualDurationInFrames,
- parentSequence?.relativeFrom,
+ parentSequence,
id,
+ height,
+ width,
]);
const timelineClipName = useMemo(() => {
@@ -190,11 +198,15 @@ const SequenceRefForwardingFunction: React.ForwardRefRenderFunction<
const styleIfThere = other.layout === 'none' ? undefined : other.style;
const defaultStyle: React.CSSProperties = useMemo(() => {
+ const widthValue = width ?? parentSequence?.width;
+ const heightValue = height ?? parentSequence?.height;
return {
flexDirection: undefined,
...(styleIfThere ?? {}),
+ ...(widthValue ? {width: widthValue} : {}),
+ ...(heightValue ? {height: heightValue} : {}),
};
- }, [styleIfThere]);
+ }, [height, parentSequence, styleIfThere, width]);
if (ref !== null && layout === 'none') {
throw new TypeError(
diff --git a/packages/core/src/SequenceContext.tsx b/packages/core/src/SequenceContext.tsx
index 4429f72114..9718650557 100644
--- a/packages/core/src/SequenceContext.tsx
+++ b/packages/core/src/SequenceContext.tsx
@@ -8,4 +8,6 @@ export type SequenceContextType = {
parentFrom: number;
durationInFrames: number;
id: string;
+ width: number | null;
+ height: number | null;
};
diff --git a/packages/core/src/test/use-audio-frame.test.tsx b/packages/core/src/test/use-audio-frame.test.tsx
index ffef981e28..8ff91cfe55 100644
--- a/packages/core/src/test/use-audio-frame.test.tsx
+++ b/packages/core/src/test/use-audio-frame.test.tsx
@@ -30,6 +30,8 @@ test.skip('Media start is shifted back based on sequence', () => {
parentFrom: 0,
durationInFrames: 0,
id: 'mock',
+ height: null,
+ width: null,
};
const wrapper: React.FC<{
children: React.ReactNode;