π₯ Make videos programmatically with React
remotion: Remove layout support from Track
Jonny Burger6a11fe91de00
diff --git a/packages/core/src/Track.tsx b/packages/core/src/Track.tsxindex 14acb7b32f..40fc23a813 100644--- a/packages/core/src/Track.tsx+++ b/packages/core/src/Track.tsx@@ -15,23 +15,24 @@ import {} from './timeline-track-context.js';import {withInteractivitySchema} from './with-interactivity-schema.js';-type TrackContainerProps = AbsoluteFillLayout &- Pick<SequenceProps, 'cropLeft' | 'cropRight' | 'cropTop' | 'cropBottom'>;-export type TrackProps = Omit<SequenceProps,- keyof TrackContainerProps | `_remotionInternal${string}` | 'outlineRef'-> &- (- | (TrackContainerProps & {layout: 'absolute-fill'})- | ({layout?: 'none'} & {- [Key in Exclude<keyof TrackContainerProps, 'layout'>]?: never;- })- );+ | keyof AbsoluteFillLayout+ | 'cropLeft'+ | 'cropRight'+ | 'cropTop'+ | 'cropBottom'+ | `_remotionInternal${string}`+ | 'outlineRef'+>;// A packed row has no container bar to drag. Expose its linear timing in the// inspector, but keep looping and freezing as programmatic operations.-const {freeze: _freeze, ...trackSequenceSchema} = sequenceSchema;+const {+ freeze: _freeze,+ layout: _layout,+ ...trackSequenceSchema+} = sequenceSchema;const trackSchema = {...trackSequenceSchema,@@ -53,22 +54,6 @@ const trackSchema = {hiddenFromList: false,keyframable: false,},- layout: {- ...sequenceSchema.layout,- default: 'none',- variants: {- ...sequenceSchema.layout.variants,- 'absolute-fill': {- ...sequenceSchema.layout.variants['absolute-fill'],- // Switching to layout="none" must remove the entire container- // props, including CSS properties without individual controls.- style: {type: 'hidden'},- className: {type: 'hidden'},- styleWhilePremounted: {type: 'hidden'},- styleWhilePostmounted: {type: 'hidden'},- },- },- },} as const satisfies InteractivitySchema;// Series variants share the Track foundation while retaining their own@@ -103,7 +88,7 @@ export const TrackWithoutSchema: React.FC<SequenceProps> = ({/** Groups clips on one Studio timeline row and applies Sequence timing. */export const Track = withInteractivitySchema<typeof trackSchema, TrackProps>({- Component: TrackWithoutSchema,+ Component: (props) => <TrackWithoutSchema {...props} layout="none" />,componentName: '<Track>',componentIdentity: 'dev.remotion.remotion.Track',schema: trackSchema,diff --git a/packages/core/src/use-schema.ts b/packages/core/src/use-schema.tsindex e5060c26e2..7c2f957d53 100644--- a/packages/core/src/use-schema.ts+++ b/packages/core/src/use-schema.ts@@ -388,20 +388,12 @@ export const computeEffectiveSchemaValuesDotNotation = ({merged[key] = value;}- for (const [key, field] of Object.entries(schema)) {- if (- field.type === 'enum' &&- (key in overrideValues ||- // Inspector edits update the source status before hot reload supplies- // the new props. Remove the previous variant's props during this preview.- (propStatus?.[key]?.status === 'static' &&- (merged[key] ?? field.default) !==- (currentValue[key] ?? field.default)))- ) {+ for (const key of Object.keys(overrideValues)) {+ if (schema[key]?.type === 'enum') {const propsToDeleteForKey = findPropsToDelete({schema,key,- value: merged[key] ?? field.default,+ value: merged[key],});for (const propToDelete of propsToDeleteForKey) {propsToDelete.add(propToDelete);diff --git a/packages/docs/docs/track.mdx b/packages/docs/docs/track.mdxindex ace313f706..3a0ced5779 100644--- a/packages/docs/docs/track.mdx+++ b/packages/docs/docs/track.mdx@@ -72,73 +72,33 @@ Repeat the selected child range until the parent ends. Defaults to `false` and rHold the children at a local frame. Defaults to `null`. See [`freeze`](/docs/sequence#freeze).-### `layout?`--Defaults to `"none"`, so the track adds no container element. Set `layout="absolute-fill"` to create a container for styling, cropping, premounting, or postmounting.--### `style?`--Styles for the container. Requires `layout="absolute-fill"`. See [`style`](/docs/sequence#style).--### `className?`--A CSS class for the container. Requires `layout="absolute-fill"`.-### `width?`-Override the width returned by [`useVideoConfig()`](/docs/use-video-config). Also sets the container width when `layout="absolute-fill"`.+Override the width returned by [`useVideoConfig()`](/docs/use-video-config) for children.### `height?`-Override the height returned by [`useVideoConfig()`](/docs/use-video-config). Also sets the container height when `layout="absolute-fill"`.--### `cropLeft?`--Crop the left edge as a fraction between `0` and `1`. Defaults to `0` and requires `layout="absolute-fill"`. See [cropping](/docs/sequence#cropleft).--### `cropRight?`--Crop the right edge. Same range, default, and layout requirement as `cropLeft`.--### `cropTop?`--Crop the top edge. Same range, default, and layout requirement as `cropLeft`.+Override the height returned by [`useVideoConfig()`](/docs/use-video-config) for children.-### `cropBottom?`--Crop the bottom edge. Same range, default, and layout requirement as `cropLeft`.--### `premountFor?`--Mount the children before the track starts. Requires `layout="absolute-fill"`. See [`premountFor`](/docs/sequence#premountfor).--### `postmountFor?`--Keep the children mounted after the track ends. Defaults to `0` and requires `layout="absolute-fill"`. See [`postmountFor`](/docs/sequence#postmountfor).--### `styleWhilePremounted?`--Override container styles while premounted. Requires `layout="absolute-fill"`. See [`styleWhilePremounted`](/docs/sequence#stylewhilepremounted).+### `controls?`-### `styleWhilePostmounted?`+Pass controls from [`Interactive.withSchema()`](/docs/interactive-with-schema) when using a track inside a custom interactive component.-Override container styles while postmounted. Requires `layout="absolute-fill"`. See [`styleWhilePostmounted`](/docs/sequence#stylewhilepostmounted).+## Styling-### `controls?`+`<Track>` does not create a container element and has no `layout` prop. Wrap its children in a `<div>` or [`<AbsoluteFill>`](/docs/absolute-fill) to apply styles or a class name.-Pass controls from [`Interactive.withSchema()`](/docs/interactive-with-schema) when using a track inside a custom interactive component.+Use [`<Sequence>`](/docs/sequence) for cropping, premounting, or postmounting. These container props are not supported on `<Track>`.## Studio interactions<AvailableFrom v="4.0.535" />-Select the track header to edit its start, duration, trim, playback rate, and layout in the inspector. With `layout="absolute-fill"`, the existing Sequence controls for transforms, opacity, background, borders, cropping, and premounting are available.--Switching to `layout="none"` removes the container's styles, class name, crop, and mounting props. Undo restores them.+Select the track header to edit From, Duration, Trim before, and Playback rate in the inspector.-Child clips can be moved and trimmed using their own timeline handles. The track container's timing is edited in the inspector; splitting the container is unavailable.+Child clips can be moved and trimmed using their own timeline handles. The track's timing is edited in the inspector; splitting a track is unavailable.Set `loop` and `freeze` in code. When either is active, the packed timeline displays one block for the track and hides its descendant rows. A repeated or frozen child does not have a single advancing interval that a packed clip could accurately represent.-`className`, `width`, `height`, `postmountFor`, and the styles applied during premounting or postmounting remain code-only. Packed rows do not display premount bars.+`width` and `height` remain code-only.## Compatibilitydiff --git a/packages/example/src/TrackSequenceProps.tsx b/packages/example/src/TrackSequenceProps.tsxindex ce283082d0..c0e168a6bb 100644--- a/packages/example/src/TrackSequenceProps.tsx+++ b/packages/example/src/TrackSequenceProps.tsx@@ -1,5 +1,5 @@import React from 'react';-import {Sequence, Track, useCurrentFrame} from 'remotion';+import {AbsoluteFill, Sequence, Track, useCurrentFrame} from 'remotion';const FrameClock: React.FC<{readonly label: string}> = ({label}) => {const frame = useCurrentFrame();@@ -41,46 +41,42 @@ export const TrackSequenceProps: React.FC = () => {overflow: 'hidden',}}>- <div style={{padding: 28, color: '#acb8c8'}}>- Premounted on frames 15β29, postmounted on frames 75β89.- </div><Trackname="Timed Track"from={30}trimBefore={15}playbackRate={2}durationInFrames={90}- layout="absolute-fill"- className="track-sequence-container"- premountFor={15}- postmountFor={15}- style={{display: 'block', padding: 28, backgroundColor: '#243345'}}- styleWhilePremounted={{opacity: 0.15}}- styleWhilePostmounted={{opacity: 0.15}}>- <FrameClock label="Track local frame" />- <div style={{marginTop: 24}}>- <Sequence name="Child A" durationInFrames={45} layout="none">- <div style={{color: '#7de1c0', marginBottom: 12}}>- Child A β composition frames 30β44- </div>- <FrameClock label="Child A local frame" />- </Sequence>- <Sequence- name="Child B clipped by Track"- from={45}- durationInFrames={90}- layout="none"- >- <div style={{color: '#e8bf7d', marginBottom: 12}}>- Child B β composition frames 45β74- </div>- <FrameClock label="Child B local frame" />- <div style={{fontSize: 20, marginTop: 16}}>- Its 90-frame duration is clipped when the Track ends.- </div>- </Sequence>- </div>+ <AbsoluteFill+ showInTimeline={false}+ className="track-sequence-container"+ style={{display: 'block', padding: 28, backgroundColor: '#243345'}}+ >+ <FrameClock label="Track local frame" />+ <div style={{marginTop: 24}}>+ <Sequence name="Child A" durationInFrames={45} layout="none">+ <div style={{color: '#7de1c0', marginBottom: 12}}>+ Child A β composition frames 30β44+ </div>+ <FrameClock label="Child A local frame" />+ </Sequence>+ <Sequence+ name="Child B clipped by Track"+ from={45}+ durationInFrames={90}+ layout="none"+ >+ <div style={{color: '#e8bf7d', marginBottom: 12}}>+ Child B β composition frames 45β74+ </div>+ <FrameClock label="Child B local frame" />+ <div style={{fontSize: 20, marginTop: 16}}>+ Its 90-frame duration is clipped when the Track ends.+ </div>+ </Sequence>+ </div>+ </AbsoluteFill></Track></div><div style={{display: 'flex', gap: 20, marginTop: 20}}>@@ -92,28 +88,34 @@ export const TrackSequenceProps: React.FC = () => {durationInFrames={30}playbackRate={2}loop- layout="absolute-fill"width={590}height={140}- cropRight={0.02}- style={{display: 'block', padding: 20, backgroundColor: '#254a42'}}>- <FrameClock label="Looped Track frame" />- <Sequence- name="Loop first half"- durationInFrames={25}- layout="none"- >- First half (local frames 10β24)- </Sequence>- <Sequence- name="Loop second half"- from={25}- durationInFrames={15}- layout="none"+ <AbsoluteFill+ showInTimeline={false}+ style={{+ display: 'block',+ padding: 20,+ backgroundColor: '#254a42',+ }}>- Second half (local frames 25β39)- </Sequence>+ <FrameClock label="Looped Track frame" />+ <Sequence+ name="Loop first half"+ durationInFrames={25}+ layout="none"+ >+ First half (local frames 10β24)+ </Sequence>+ <Sequence+ name="Loop second half"+ from={25}+ durationInFrames={15}+ layout="none"+ >+ Second half (local frames 25β39)+ </Sequence>+ </AbsoluteFill></Track></div><div style={{position: 'relative', width: 590, height: 140}}>@@ -122,20 +124,27 @@ export const TrackSequenceProps: React.FC = () => {from={15}durationInFrames={90}freeze={20}- layout="absolute-fill"- style={{display: 'block', padding: 20, backgroundColor: '#4a3c25'}}>- <FrameClock label="Frozen Track frame" />- <Sequence- name="Frozen visible child"- durationInFrames={30}- layout="none"+ <AbsoluteFill+ showInTimeline={false}+ style={{+ display: 'block',+ padding: 20,+ backgroundColor: '#4a3c25',+ }}>- Held inside the first child at frame 20.- </Sequence>- <Sequence name="Frozen inactive child" from={30} layout="none">- This child should stay hidden.- </Sequence>+ <FrameClock label="Frozen Track frame" />+ <Sequence+ name="Frozen visible child"+ durationInFrames={30}+ layout="none"+ >+ Held inside the first child at frame 20.+ </Sequence>+ <Sequence name="Frozen inactive child" from={30} layout="none">+ This child should stay hidden.+ </Sequence>+ </AbsoluteFill></Track></div></div>