Skip to content

🎥 Make videos programmatically with React

Test `trimAfter` and complete loop support

Jonny Burger2635b4437078
diff --git a/packages/core/src/Img.tsx b/packages/core/src/Img.tsx
index e862236763..f8a150175d 100644
--- a/packages/core/src/Img.tsx
+++ b/packages/core/src/Img.tsx
@@ -69,7 +69,7 @@ export type ImgProps = NativeImgProps & {
readonly effects?: EffectsProp;
readonly showInTimeline?: boolean;
readonly name?: string;
-} & Omit<InteractiveBaseProps, 'playbackRate' | 'loop'> &
+} & Omit<InteractiveBaseProps, 'playbackRate'> &
InteractiveCropProps &
InteractivePremountProps;
@@ -86,6 +86,7 @@ type ImgContentProps = Omit<
| 'from'
| 'trimBefore'
| 'trimAfter'
+ | 'loop'
| 'durationInFrames'
| 'freeze'
| 'effects'
@@ -369,6 +370,7 @@ const NativeImgInner: React.FC<NativeImgInnerProps> = ({
from,
trimBefore,
trimAfter,
+ loop,
durationInFrames,
freeze,
premountFor,
@@ -411,7 +413,7 @@ const NativeImgInner: React.FC<NativeImgInnerProps> = ({
trimBefore,
trimAfter,
playbackRate: undefined,
- loop: undefined,
+ loop,
}),
premountFor: premountFor ?? null,
postmountFor: postmountFor ?? null,
@@ -436,6 +438,7 @@ const NativeImgInner: React.FC<NativeImgInnerProps> = ({
from={from ?? 0}
trimBefore={trimBefore}
trimAfter={trimAfter}
+ loop={loop}
durationInFrames={durationInFrames ?? Infinity}
freeze={freeze}
_remotionInternalDocumentationLink="https://www.remotion.dev/docs/img"
diff --git a/packages/core/src/Interactive.tsx b/packages/core/src/Interactive.tsx
index 42801372a6..bc87beaece 100644
--- a/packages/core/src/Interactive.tsx
+++ b/packages/core/src/Interactive.tsx
@@ -8,7 +8,6 @@ import {Freeze} from './freeze.js';
import {
backgroundSchema,
baseSchema,
- baseSchemaWithoutLoop,
borderRadiusSchema,
captionsSchema,
borderSchema,
@@ -390,7 +389,6 @@ const makeInteractiveSvgStrokeElement = <Tag extends InteractiveSvgTag>(
*/
export const Interactive = {
baseSchema,
- baseSchemaWithoutLoop,
captionsSchema,
transformSchema,
textSchema,
diff --git a/packages/core/src/animated-image/AnimatedImage.tsx b/packages/core/src/animated-image/AnimatedImage.tsx
index bbd0777848..fb7ab81e3a 100644
--- a/packages/core/src/animated-image/AnimatedImage.tsx
+++ b/packages/core/src/animated-image/AnimatedImage.tsx
@@ -18,7 +18,7 @@ import {addSequenceStackTraces} from '../enable-sequence-stack-traces.js';
import {Freeze} from '../freeze.js';
import {
backgroundSchema,
- baseSchemaWithoutLoop,
+ baseSchema,
borderRadiusSchema,
borderSchema,
cropSchema,
@@ -55,8 +55,7 @@ export const animatedImageSchema = {
description: 'Source',
keyframable: false,
},
- // Looping is controlled by `loopBehavior`, which repeats the intrinsic duration.
- ...baseSchemaWithoutLoop,
+ ...baseSchema,
...cropSchema,
...premountSchema,
...transformSchema,
@@ -340,7 +339,7 @@ const AnimatedImageInner = ({
trimBefore: sequenceProps.trimBefore,
trimAfter: sequenceProps.trimAfter,
playbackRate,
- loop: undefined,
+ loop: sequenceProps.loop,
}),
premountFor: premountFor ?? null,
postmountFor: postmountFor ?? null,
diff --git a/packages/core/src/animated-image/props.ts b/packages/core/src/animated-image/props.ts
index 907d712cb4..b118d579c0 100644
--- a/packages/core/src/animated-image/props.ts
+++ b/packages/core/src/animated-image/props.ts
@@ -28,7 +28,7 @@ export type RemotionAnimatedImageProps = {
requestInit?: RequestInit;
} & AnimatedImageCanvasProps;
-export type AnimatedImageProps = Omit<InteractiveBaseProps, 'loop'> &
+export type AnimatedImageProps = InteractiveBaseProps &
InteractiveCropProps &
InteractivePremountProps &
RemotionAnimatedImageProps & {
diff --git a/packages/core/src/canvas-image/CanvasImage.tsx b/packages/core/src/canvas-image/CanvasImage.tsx
index a043d1a0e4..96a4f9fe1e 100644
--- a/packages/core/src/canvas-image/CanvasImage.tsx
+++ b/packages/core/src/canvas-image/CanvasImage.tsx
@@ -545,6 +545,7 @@ const CanvasImageInner = forwardRef<
from,
trimBefore,
trimAfter,
+ loop,
freeze,
premountFor,
postmountFor,
@@ -597,7 +598,7 @@ const CanvasImageInner = forwardRef<
trimBefore,
trimAfter,
playbackRate: undefined,
- loop: undefined,
+ loop,
}),
premountFor: premountFor ?? null,
postmountFor: postmountFor ?? null,
@@ -622,6 +623,7 @@ const CanvasImageInner = forwardRef<
from={from ?? 0}
trimBefore={trimBefore}
trimAfter={trimAfter}
+ loop={loop}
durationInFrames={durationInFrames ?? Infinity}
freeze={freeze}
hidden={hidden}
diff --git a/packages/core/src/canvas-image/props.ts b/packages/core/src/canvas-image/props.ts
index 20c04ff21a..8fbcc7f8b4 100644
--- a/packages/core/src/canvas-image/props.ts
+++ b/packages/core/src/canvas-image/props.ts
@@ -7,10 +7,7 @@ import type {
InteractivePremountProps,
} from '../Interactive.js';
-type CanvasImageSequenceProps = Omit<
- InteractiveBaseProps,
- 'playbackRate' | 'loop'
-> &
+type CanvasImageSequenceProps = Omit<InteractiveBaseProps, 'playbackRate'> &
InteractiveCropProps &
InteractivePremountProps;
diff --git a/packages/core/src/effects/Solid.tsx b/packages/core/src/effects/Solid.tsx
index 16fee11107..1f940a565d 100644
--- a/packages/core/src/effects/Solid.tsx
+++ b/packages/core/src/effects/Solid.tsx
@@ -17,7 +17,7 @@ import type {
} from '../Interactive.js';
import {
backgroundSchema,
- baseSchemaWithoutLoop,
+ baseSchema,
premountSchema,
borderRadiusSchema,
borderSchema,
@@ -78,9 +78,8 @@ export type SolidProps = MandatoryProps &
Partial<OptionalProps> &
InteractiveCropProps;
-// A solid color does not change with the frame, so looping it would be inert.
export const solidSchema = {
- ...baseSchemaWithoutLoop,
+ ...baseSchema,
...premountSchema,
color: {
type: 'color',
@@ -261,7 +260,7 @@ const SolidOuter = forwardRef<
HTMLCanvasElement,
SolidProps & {
readonly controls: SequenceControls | undefined;
- } & Omit<InteractiveBaseProps, 'loop'> &
+ } & InteractiveBaseProps &
InteractivePremountProps
>(
(
@@ -283,6 +282,7 @@ const SolidOuter = forwardRef<
trimBefore,
trimAfter,
playbackRate,
+ loop,
freeze,
hidden,
showInTimeline,
@@ -318,7 +318,7 @@ const SolidOuter = forwardRef<
trimBefore,
trimAfter,
playbackRate,
- loop: undefined,
+ loop,
}),
premountFor: premountFor ?? null,
postmountFor: postmountFor ?? null,
@@ -344,6 +344,7 @@ const SolidOuter = forwardRef<
trimBefore={trimBefore}
trimAfter={trimAfter}
playbackRate={playbackRate}
+ loop={loop}
freeze={freeze}
hidden={hidden}
showInTimeline={showInTimeline}
diff --git a/packages/core/src/interactivity-schema.ts b/packages/core/src/interactivity-schema.ts
index 7a156819c9..ecb5d38f4e 100644
--- a/packages/core/src/interactivity-schema.ts
+++ b/packages/core/src/interactivity-schema.ts
@@ -656,26 +656,13 @@ export const baseSchema = {
showInTimeline: showInTimelineField,
} as const satisfies InteractivitySchema;
-// For components whose content does not advance with the frame, or which
-// implement their own looping, so that a `loop` control is never inert.
-export const baseSchemaWithoutLoop = {
- durationInFrames: durationInFramesField,
- from: fromField,
- trimBefore: trimBeforeField,
- trimAfter: trimAfterField,
- playbackRate: playbackRateField,
- freeze: freezeField,
- hidden: hiddenField,
- name: sequenceNameField,
- showInTimeline: showInTimelineField,
-} as const satisfies InteractivitySchema;
-
-// For static images: neither speed nor looping changes what they show.
+// For static images: speed does not change what they show.
export const baseSchemaWithoutPlaybackRate = {
durationInFrames: durationInFramesField,
from: fromField,
trimBefore: trimBeforeField,
trimAfter: trimAfterField,
+ loop: loopField,
freeze: freezeField,
hidden: hiddenField,
name: sequenceNameField,
diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.ts
index 84087620d9..450881bf05 100644
--- a/packages/core/src/internals.ts
+++ b/packages/core/src/internals.ts
@@ -97,7 +97,6 @@ import {
import type {SerializedJSONWithCustomFields} from './input-props-serialization.js';
import {
baseSchema,
- baseSchemaWithoutLoop,
durationInFramesField,
freezeField,
fromField,
@@ -354,7 +353,6 @@ export const Internals = {
SequenceOutlineContext,
SequenceStackTracesUpdateContext,
baseSchema,
- baseSchemaWithoutLoop,
sequenceSchema,
SequenceWithoutSchema,
sequenceStyleSchema,
diff --git a/packages/core/src/test/sequence-trim-after-loop.test.tsx b/packages/core/src/test/sequence-trim-after-loop.test.tsx
new file mode 100644
index 0000000000..cbc76bfa0d
--- /dev/null
+++ b/packages/core/src/test/sequence-trim-after-loop.test.tsx
@@ -0,0 +1,197 @@
+import {afterEach, expect, test} from 'bun:test';
+import {cleanup, render} from '@testing-library/react';
+import type {ReactNode} from 'react';
+import {AbsoluteFill} from '../AbsoluteFill.js';
+import {Loop} from '../loop/index.js';
+import {Sequence} from '../Sequence.js';
+import {Series} from '../series/index.js';
+import {useCurrentFrame} from '../use-current-frame.js';
+import {useVideoConfig} from '../use-video-config.js';
+import {WrapSequenceContext} from './wrap-sequence-context.js';
+
+afterEach(cleanup);
+
+const Clock = ({label}: {readonly label: string}) => {
+ const frame = useCurrentFrame();
+ const {durationInFrames} = useVideoConfig();
+ const loop = Loop.useLoop();
+ const format = (value: number) => Number(value.toFixed(10));
+
+ return (
+ <div>{`${label}: frame ${format(frame)}, duration ${format(
+ durationInFrames,
+ )}, iteration ${loop?.iteration ?? 'none'}, period ${
+ loop ? format(loop.durationInFrames) : 'none'
+ }`}</div>
+ );
+};
+
+const renderFrame = ({
+ frame,
+ children,
+ compositionDurationInFrames = 100,
+}: {
+ readonly frame: number;
+ readonly children: ReactNode;
+ readonly compositionDurationInFrames?: number;
+}) => {
+ return (
+ <WrapSequenceContext
+ currentFrame={frame}
+ compositionDurationInFrames={compositionDurationInFrames}
+ >
+ {children}
+ </WrapSequenceContext>
+ );
+};
+
+test('trimAfter uses the child clock and the earliest end wins', () => {
+ const content = (durationInFrames: number) => (
+ <Sequence
+ layout="none"
+ from={5}
+ trimBefore={10}
+ trimAfter={18}
+ playbackRate={2}
+ durationInFrames={durationInFrames}
+ >
+ <Clock label="clock" />
+ </Sequence>
+ );
+ const view = render(renderFrame({frame: 4, children: content(10)}));
+
+ expect(view.container.textContent).toBe('');
+ view.rerender(renderFrame({frame: 5, children: content(10)}));
+ expect(view.container.textContent).toBe(
+ 'clock: frame 10, duration 18, iteration none, period none',
+ );
+ view.rerender(renderFrame({frame: 8, children: content(10)}));
+ expect(view.container.textContent).toBe(
+ 'clock: frame 16, duration 18, iteration none, period none',
+ );
+ view.rerender(renderFrame({frame: 9, children: content(10)}));
+ expect(view.container.textContent).toBe('');
+
+ view.rerender(renderFrame({frame: 6, children: content(2)}));
+ expect(view.container.textContent).toBe(
+ 'clock: frame 12, duration 14, iteration none, period none',
+ );
+ view.rerender(renderFrame({frame: 7, children: content(2)}));
+ expect(view.container.textContent).toBe('');
+});
+
+test('loop repeats the trimmed range and exposes a partial final iteration', () => {
+ const content = (
+ <Sequence
+ layout="none"
+ from={3}
+ trimBefore={10}
+ trimAfter={16}
+ playbackRate={2}
+ durationInFrames={8}
+ loop
+ >
+ <Clock label="clock" />
+ </Sequence>
+ );
+ const view = render(renderFrame({frame: 2, children: content}));
+
+ expect(view.container.textContent).toBe('');
+ for (const [frame, expected] of [
+ [3, 'clock: frame 10, duration 16, iteration 0, period 3'],
+ [5, 'clock: frame 14, duration 16, iteration 0, period 3'],
+ [6, 'clock: frame 10, duration 16, iteration 1, period 3'],
+ [9, 'clock: frame 10, duration 14, iteration 2, period 3'],
+ [10, 'clock: frame 12, duration 14, iteration 2, period 3'],
+ ] as const) {
+ view.rerender(renderFrame({frame, children: content}));
+ expect(view.container.textContent).toBe(expected);
+ }
+
+ view.rerender(renderFrame({frame: 5, children: content}));
+ expect(view.container.textContent).toBe(
+ 'clock: frame 14, duration 16, iteration 0, period 3',
+ );
+ view.rerender(renderFrame({frame: 11, children: content}));
+ expect(view.container.textContent).toBe('');
+});
+
+test('loop respects nested playback rates and a parent cutting an iteration short', () => {
+ const fractionalBoundary = (
+ <Sequence layout="none" playbackRate={0.3} durationInFrames={20}>
+ <Sequence layout="none" trimAfter={1} loop>
+ <Clock label="fractional" />
+ </Sequence>
+ </Sequence>
+ );
+ const view = render(renderFrame({frame: 10, children: fractionalBoundary}));
+ expect(view.container.textContent).toBe(
+ 'fractional: frame 0, duration 1, iteration 3, period 1',
+ );
+
+ const parentCutoff = (
+ <Sequence layout="none" durationInFrames={7}>
+ <Sequence layout="none" trimAfter={4} loop>
+ <Clock label="cutoff" />
+ </Sequence>
+ </Sequence>
+ );
+ view.unmount();
+ const cutoffView = render(renderFrame({frame: 6, children: parentCutoff}));
+ expect(cutoffView.container.textContent).toBe(
+ 'cutoff: frame 2, duration 3, iteration 1, period 4',
+ );
+ cutoffView.rerender(renderFrame({frame: 7, children: parentCutoff}));
+ expect(cutoffView.container.textContent).toBe('');
+});
+
+test('Sequence loop matches Loop and timed wrappers forward the props', () => {
+ const content = (
+ <>
+ <Loop durationInFrames={5} times={3} layout="none">
+ <Clock label="Loop" />
+ </Loop>
+ <Sequence layout="none" trimAfter={5} durationInFrames={15} loop>
+ <Clock label="Sequence" />
+ </Sequence>
+ <AbsoluteFill
+ from={2}
+ trimBefore={4}
+ trimAfter={6}
+ durationInFrames={5}
+ loop
+ >
+ <Clock label="AbsoluteFill" />
+ </AbsoluteFill>
+ </>
+ );
+ const view = render(renderFrame({frame: 5, children: content}));
+ expect(
+ view.getByText('Loop: frame 0, duration 5, iteration 1, period 5'),
+ ).toBeTruthy();
+ expect(
+ view.getByText('Sequence: frame 0, duration 5, iteration 1, period 5'),
+ ).toBeTruthy();
+ expect(
+ view.getByText('AbsoluteFill: frame 5, duration 6, iteration 1, period 2'),
+ ).toBeTruthy();
+
+ const series = (
+ <Series>
+ <Series.Sequence layout="none" durationInFrames={5} trimAfter={2} loop>
+ <Clock label="first" />
+ </Series.Sequence>
+ <Series.Sequence layout="none" durationInFrames={3}>
+ <Clock label="second" />
+ </Series.Sequence>
+ </Series>
+ );
+ view.rerender(renderFrame({frame: 4, children: series}));
+ expect(view.container.textContent).toBe(
+ 'first: frame 0, duration 1, iteration 2, period 2',
+ );
+ view.rerender(renderFrame({frame: 5, children: series}));
+ expect(view.container.textContent).toBe(
+ 'second: frame 0, duration 3, iteration none, period none',
+ );
+});
diff --git a/packages/core/src/test/sequence-validation.test.tsx b/packages/core/src/test/sequence-validation.test.tsx
index 6cfa494576..b7f1642728 100644
--- a/packages/core/src/test/sequence-validation.test.tsx
+++ b/packages/core/src/test/sequence-validation.test.tsx
@@ -103,6 +103,69 @@ describe('Composition-validation render should throw with invalid props', () =>
);
});
});
+ describe('Throw with invalid trimAfter and loop props', () => {
+ test('trimAfter must be a number greater than trimBefore', () => {
+ for (const [trimBefore, trimAfter, expected] of [
+ [
+ 0,
+ '30',
+ /The "trimAfter" prop of <Sequence \/> must be a number, but is of type string./,
+ ],
+ [
+ 0,
+ NaN,
+ /The "trimAfter" prop of <Sequence \/> must be a real number, but it is NaN./,
+ ],
+ [
+ 10,
+ 10,
+ /The "trimAfter" prop of <Sequence \/> must be greater than "trimBefore" \(10\), but got 10./,
+ ],
+ [
+ 10,
+ 9,
+ /The "trimAfter" prop of <Sequence \/> must be greater than "trimBefore" \(10\), but got 9./,
+ ],
+ ] as const) {
+ expectToThrow(
+ () =>
+ render(
+ <WrapSequenceContext>
+ <Sequence
+ trimBefore={trimBefore}
+ trimAfter={trimAfter as number}
+ />
+ </WrapSequenceContext>,
+ ),
+ expected,
+ );
+ }
+ });
+
+ test('loop must be boolean and requires a finite trimAfter', () => {
+ expectToThrow(
+ () =>
+ render(
+ <WrapSequenceContext>
+ <Sequence loop={'true' as unknown as boolean} trimAfter={30} />
+ </WrapSequenceContext>,
+ ),
+ /The "loop" prop of <Sequence \/> must be a boolean, but is of type string./,
+ );
+
+ for (const trimAfter of [undefined, Infinity]) {
+ expectToThrow(
+ () =>
+ render(
+ <WrapSequenceContext>
+ <Sequence loop trimAfter={trimAfter} durationInFrames={30} />
+ </WrapSequenceContext>,
+ ),
+ /requires a finite "trimAfter" prop/,
+ );
+ }
+ });
+ });
describe('Throw with invalid freeze props', () => {
test('It should throw if "freeze" prop is not a number', () => {
expectToThrow(
diff --git a/packages/core/src/test/with-interactivity-schema-helpers.test.ts b/packages/core/src/test/with-interactivity-schema-helpers.test.ts
index bf6c9206f7..66e92e185d 100644
--- a/packages/core/src/test/with-interactivity-schema-helpers.test.ts
+++ b/packages/core/src/test/with-interactivity-schema-helpers.test.ts
@@ -154,6 +154,14 @@ test('baseSchema exposes common timeline fields', () => {
'loop',
].sort(),
);
+ for (const schema of [
+ imgSchema,
+ animatedImageSchema,
+ canvasImageSchema,
+ solidSchema,
+ ]) {
+ expect(schema.loop).toBe(baseSchema.loop);
+ }
});
test('pixelDensity is exposed only by canvas-backed component schemas', () => {
diff --git a/packages/docs/docs/interactive.mdx b/packages/docs/docs/interactive.mdx
index 9280a3a95f..694050e5ec 100644
--- a/packages/docs/docs/interactive.mdx
+++ b/packages/docs/docs/interactive.mdx
@@ -90,12 +90,6 @@ export const shapeSchema = {
} as const satisfies InteractivitySchema;
```
-### `Interactive.baseSchemaWithoutLoop`
-
-The same controls as [`Interactive.baseSchema`](#interactivebaseschema) without `loop`.
-
-Use it for components whose output does not change with the frame, such as a static image or shape, so that the Studio does not show a `Loop` toggle that has no effect.
-
### `Interactive.transformSchema`<AvailableFrom v="4.0.479" />
Controls for transform-related style props:
diff --git a/packages/docs/docs/interactivity-schema.mdx b/packages/docs/docs/interactivity-schema.mdx
index aeeee799b5..f1216a9945 100644
--- a/packages/docs/docs/interactivity-schema.mdx
+++ b/packages/docs/docs/interactivity-schema.mdx
@@ -39,8 +39,6 @@ Keys may use dot notation. For example, a key named `style.opacity` reads from a
Timeline props inherited from [`<Sequence>`](/docs/sequence): [`durationInFrames`](/docs/sequence#durationinframes), [`from`](/docs/sequence#from), [`trimBefore`](/docs/sequence#trimbefore), [`trimAfter`](/docs/sequence#trimafter), [`playbackRate`](/docs/sequence#playbackrate), [`loop`](/docs/sequence#loop), [`freeze`](/docs/sequence#freeze), [`hidden`](/docs/sequence#hidden), [`name`](/docs/sequence#name) and [`showInTimeline`](/docs/sequence#showintimeline).
-Use [`Interactive.baseSchemaWithoutLoop`](/docs/interactive#interactivebaseschemawithoutloop) for components whose output does not change with the frame.
-
### `Interactive.captionsSchema`<AvailableFrom v="4.0.500" />
A `captions` field for components that accept [`Caption[]`](/docs/captions/caption) data. It enables the captions inspector and is not keyframable.
diff --git a/packages/docs/docs/studio/make-component-interactive.mdx b/packages/docs/docs/studio/make-component-interactive.mdx
index 7205d392f5..99670238a1 100644
--- a/packages/docs/docs/studio/make-component-interactive.mdx
+++ b/packages/docs/docs/studio/make-component-interactive.mdx
@@ -18,7 +18,6 @@ An [`InteractivitySchema`](/docs/interactivity-schema) describes which props the
Use [`Interactive.baseSchema`](/docs/interactive#interactivebaseschema) for props inherited from [`<Sequence>`](/docs/sequence), such as [`from`](/docs/sequence#from), [`trimBefore`](/docs/sequence#trimbefore), [`trimAfter`](/docs/sequence#trimafter), [`playbackRate`](/docs/sequence#playbackrate), [`loop`](/docs/sequence#loop), [`durationInFrames`](/docs/sequence#durationinframes), [`freeze`](/docs/sequence#freeze), [`hidden`](/docs/sequence#hidden), [`name`](/docs/sequence#name) and [`showInTimeline`](/docs/sequence#showintimeline).
As a rule, include `Interactive.baseSchema` in every schema passed to `Interactive.withSchema()` so trimming, looping and visibility controls remain available. Forward all of these props to the `<Sequence>` your component renders.
-If the output of your component does not change with the frame, use [`Interactive.baseSchemaWithoutLoop`](/docs/interactive#interactivebaseschemawithoutloop) instead so that no inert `Loop` control is shown.
Use [`Interactive.transformSchema`](/docs/interactive#interactivetransformschema) if your component accepts a `style` prop and applies it to the rendered element.
@@ -295,10 +294,6 @@ The component now has a timeline row, inherits the common `<Sequence>` props and
Use it when the component renders a `<Sequence>` internally.
-### `Interactive.baseSchemaWithoutLoop`
-
-Use it instead of `Interactive.baseSchema` when the output of the component does not change with the frame, so that no `Loop` control is shown.
-
### `Interactive.transformSchema`
Use it when the component accepts a `style` prop and applies it to the rendered element.
diff --git a/packages/gif/src/Gif.tsx b/packages/gif/src/Gif.tsx
index 81848d7bc2..0e87018eb7 100644
--- a/packages/gif/src/Gif.tsx
+++ b/packages/gif/src/Gif.tsx
@@ -19,7 +19,7 @@ import type {RemotionGifProps} from './props';
const {useMemoizedEffectDefinitions, useMemoizedEffects} = Internals;
-export type GifProps = Omit<InteractiveBaseProps, 'loop'> &
+export type GifProps = InteractiveBaseProps &
InteractiveCropProps &
InteractivePremountProps &
InteractiveTransformProps &
@@ -32,8 +32,7 @@ export type GifProps = Omit<InteractiveBaseProps, 'loop'> &
* @see [Documentation](https://remotion.dev/docs/gif)
*/
export const gifSchema: InteractivitySchema = {
- // Looping is controlled by `loopBehavior`, which repeats the intrinsic duration.
- ...Internals.baseSchemaWithoutLoop,
+ ...Internals.baseSchema,
...Internals.premountSchema,
...Internals.transformSchema,
...Interactive.backgroundSchema,
@@ -90,7 +89,7 @@ const GifInner = ({
trimBefore: sequenceProps.trimBefore,
trimAfter: sequenceProps.trimAfter,
playbackRate,
- loop: undefined,
+ loop: sequenceProps.loop,
}),
premountFor: premountFor ?? null,
postmountFor: postmountFor ?? null,
diff --git a/packages/gif/src/test/Gif.test.tsx b/packages/gif/src/test/Gif.test.tsx
index 31ea432363..a689c63d8f 100644
--- a/packages/gif/src/test/Gif.test.tsx
+++ b/packages/gif/src/test/Gif.test.tsx
@@ -23,6 +23,7 @@ test('Gif exposes background, border, and crop controls', () => {
expect('cropRight' in gifSchema).toBe(true);
expect('cropTop' in gifSchema).toBe(true);
expect('cropBottom' in gifSchema).toBe(true);
+ expect(gifSchema.loop).toBe(Internals.baseSchema.loop);
});
class MockWorker {
diff --git a/packages/lottie/src/Lottie.tsx b/packages/lottie/src/Lottie.tsx
index 7dc2027658..18c05172ca 100644
--- a/packages/lottie/src/Lottie.tsx
+++ b/packages/lottie/src/Lottie.tsx
@@ -183,6 +183,7 @@ export const Lottie = ({
durationInFrames,
trimBefore,
trimAfter,
+ loop,
freeze,
hidden,
name,
@@ -194,6 +195,7 @@ export const Lottie = ({
style,
...props
}: LottieProps) => {
+ const sequenceLoop = loop === true && trimAfter !== undefined;
const {
effectivePremountFor,
effectivePostmountFor,
@@ -209,7 +211,7 @@ export const Lottie = ({
trimBefore,
trimAfter,
playbackRate: undefined,
- loop: undefined,
+ loop: sequenceLoop,
}),
premountFor: premountFor ?? null,
postmountFor: postmountFor ?? null,
@@ -226,6 +228,7 @@ export const Lottie = ({
durationInFrames={durationInFrames}
trimBefore={trimBefore}
trimAfter={trimAfter}
+ loop={sequenceLoop}
freeze={freeze}
hidden={hidden}
name={name ?? '<Lottie>'}
@@ -235,7 +238,11 @@ export const Lottie = ({
_remotionInternalIsPremounting={premountingActive}
_remotionInternalIsPostmounting={postmountingActive}
>
- <LottieContent {...props} style={premountingStyle ?? undefined} />
+ <LottieContent
+ {...props}
+ loop={loop}
+ style={premountingStyle ?? undefined}
+ />
</Sequence>
</Freeze>
);
diff --git a/packages/lottie/src/types.ts b/packages/lottie/src/types.ts
index aa1d8ec9fa..86d7e400dc 100644
--- a/packages/lottie/src/types.ts
+++ b/packages/lottie/src/types.ts
@@ -20,7 +20,7 @@ export type AspectRatioConstraint =
| 'xMinYMax'
| 'xMidYMax';
-export type LottieProps = Omit<InteractiveBaseProps, 'playbackRate' | 'loop'> &
+export type LottieProps = Omit<InteractiveBaseProps, 'playbackRate'> &
InteractivePremountProps & {
/**
* JSON object with the animation data.
diff --git a/packages/mac-cursors/src/MacOSCursor.tsx b/packages/mac-cursors/src/MacOSCursor.tsx
index b3cb956642..6c407cfbcb 100644
--- a/packages/mac-cursors/src/MacOSCursor.tsx
+++ b/packages/mac-cursors/src/MacOSCursor.tsx
@@ -15,7 +15,7 @@ import {
} from 'remotion';
import {macOSCursorNames, resolveCursor} from './resolve-cursor';
-export type MacOSCursorProps = Omit<InteractiveBaseProps, 'loop'> &
+export type MacOSCursorProps = InteractiveBaseProps &
InteractivePremountProps & {
readonly cursor?: string;
readonly customCursor?: string;
@@ -24,8 +24,7 @@ export type MacOSCursorProps = Omit<InteractiveBaseProps, 'loop'> &
};
export const macOSCursorSchema: InteractivitySchema = {
- // A cursor image does not advance with the frame, so looping it would be inert.
- ...Interactive.baseSchemaWithoutLoop,
+ ...Interactive.baseSchema,
...Interactive.premountSchema,
cursor: {
type: 'enum',
@@ -67,6 +66,7 @@ const MacOSCursorInner: React.FC<
trimBefore,
trimAfter,
playbackRate,
+ loop,
freeze,
hidden,
name,
@@ -99,7 +99,7 @@ const MacOSCursorInner: React.FC<
trimBefore,
trimAfter,
playbackRate,
- loop: undefined,
+ loop,
}),
premountFor: premountFor ?? null,
postmountFor: postmountFor ?? null,
@@ -116,6 +116,7 @@ const MacOSCursorInner: React.FC<
trimBefore={trimBefore}
trimAfter={trimAfter}
playbackRate={playbackRate}
+ loop={loop}
durationInFrames={durationInFrames ?? Infinity}
freeze={freeze}
hidden={hidden}
diff --git a/packages/mac-cursors/src/test/resolve-cursor.test.ts b/packages/mac-cursors/src/test/resolve-cursor.test.ts
index 8f22fc06a6..2d31f14a40 100644
--- a/packages/mac-cursors/src/test/resolve-cursor.test.ts
+++ b/packages/mac-cursors/src/test/resolve-cursor.test.ts
@@ -65,6 +65,7 @@ test('cursor schema exposes named cursors as a keyframable enum', () => {
expect(macOSCursorSchema['style.translate'].type).toBe('translate');
expect(macOSCursorSchema['style.scale'].type).toBe('scale');
expect(macOSCursorSchema['style.rotate'].type).toBe('rotation-css');
+ expect(macOSCursorSchema.loop).toBe(Internals.baseSchema.loop);
});
test('<MacOSCursor> renders the default cursor when the cursor prop is omitted', () => {
diff --git a/packages/motion-blur/src/HtmlInCanvasMotionBlur.tsx b/packages/motion-blur/src/HtmlInCanvasMotionBlur.tsx
index 0633880576..4d91d812c2 100644
--- a/packages/motion-blur/src/HtmlInCanvasMotionBlur.tsx
+++ b/packages/motion-blur/src/HtmlInCanvasMotionBlur.tsx
@@ -11,7 +11,12 @@ import {
export type HtmlInCanvasMotionBlurProps = Pick<
HtmlInCanvasProps,
- 'from' | 'durationInFrames' | 'trimBefore' | 'trimAfter' | 'playbackRate'
+ | 'from'
+ | 'durationInFrames'
+ | 'trimBefore'
+ | 'trimAfter'
+ | 'playbackRate'
+ | 'loop'
> & {
readonly children: React.ReactNode;
readonly width: number;
@@ -86,6 +91,7 @@ export const HtmlInCanvasMotionBlur: React.FC<HtmlInCanvasMotionBlurProps> = ({
trimBefore,
trimAfter,
playbackRate,
+ loop,
}) => {
const {durationInFrames: compositionDurationInFrames} = useVideoConfig();
@@ -117,7 +123,7 @@ export const HtmlInCanvasMotionBlur: React.FC<HtmlInCanvasMotionBlurProps> = ({
trimBefore,
trimAfter,
playbackRate,
- loop: undefined,
+ loop,
}),
compositionDurationInFrames - (from ?? 0),
),
@@ -197,6 +203,7 @@ export const HtmlInCanvasMotionBlur: React.FC<HtmlInCanvasMotionBlurProps> = ({
trimBefore={trimBefore}
trimAfter={trimAfter}
playbackRate={playbackRate}
+ loop={loop}
name="<HtmlInCanvasMotionBlur>"
onPaint={onPaint}
_remotionInternalCanvasSiblings={sampleElements.slice(1)}
diff --git a/packages/rough-notation/src/Annotation.tsx b/packages/rough-notation/src/Annotation.tsx
index 1773767e31..7f03d599cf 100644
--- a/packages/rough-notation/src/Annotation.tsx
+++ b/packages/rough-notation/src/Annotation.tsx
@@ -37,7 +37,7 @@ type SharedAnnotationComponentProps = Readonly<
type AnnotationInteractiveProps<Config> = SharedAnnotationComponentProps &
Readonly<Config> &
- Omit<InteractiveBaseProps, 'loop'> &
+ InteractiveBaseProps &
InteractivePremountProps;
export type HighlightProps = AnnotationInteractiveProps<HighlightConfig>;
@@ -52,7 +52,7 @@ export type CircleProps = AnnotationInteractiveProps<
>;
type InternalAnnotationProps = SharedAnnotationComponentProps &
- Omit<InteractiveBaseProps, 'loop'> &
+ InteractiveBaseProps &
InteractivePremountProps & {
readonly color?: string;
readonly strokeWidth?: number;
@@ -216,8 +216,7 @@ const textContentSchema = {
} as const satisfies InteractivitySchema;
const sharedSchema = (defaultRoughness: number): InteractivitySchema => ({
- // The drawing is driven by `progress`, so a loop control would be inert.
- ...Interactive.baseSchemaWithoutLoop,
+ ...Interactive.baseSchema,
...Interactive.premountSchema,
progress: {
type: 'number',
@@ -372,6 +371,7 @@ const makeAnnotationComponent = ({
trimBefore,
trimAfter,
playbackRate,
+ loop,
freeze,
hidden,
name,
@@ -429,7 +429,7 @@ const makeAnnotationComponent = ({
trimBefore,
trimAfter,
playbackRate,
- loop: undefined,
+ loop,
}),
premountFor: premountFor ?? null,
postmountFor: postmountFor ?? null,
@@ -446,6 +446,7 @@ const makeAnnotationComponent = ({
trimBefore={trimBefore}
trimAfter={trimAfter}
playbackRate={playbackRate}
+ loop={loop}
durationInFrames={durationInFrames ?? Infinity}
freeze={freeze}
hidden={hidden}
diff --git a/packages/rough-notation/src/test/annotation-schema.test.ts b/packages/rough-notation/src/test/annotation-schema.test.ts
index 8f0667afb8..fed02aa889 100644
--- a/packages/rough-notation/src/test/annotation-schema.test.ts
+++ b/packages/rough-notation/src/test/annotation-schema.test.ts
@@ -69,6 +69,7 @@ test('all named annotations expose text, font, border, and seed controls', () =>
expect(keys(schema)).toContain('style.borderWidth');
expect(keys(schema)).toContain('style.borderStyle');
expect(keys(schema)).toContain('style.borderColor');
+ expect(schema.loop).toBe(Internals.baseSchema.loop);
expect(schema.seed).not.toHaveProperty('keyframable', false);
}
});
diff --git a/packages/shapes/src/components/render-svg.tsx b/packages/shapes/src/components/render-svg.tsx
index fea4581ab3..da2bafca97 100644
--- a/packages/shapes/src/components/render-svg.tsx
+++ b/packages/shapes/src/components/render-svg.tsx
@@ -15,7 +15,7 @@ import {
} from 'remotion';
import {doesReactSupportTransformOriginProperty} from '../utils/does-react-support-canary';
-type ShapeSequenceProps = Omit<InteractiveBaseProps, 'loop'> &
+type ShapeSequenceProps = InteractiveBaseProps &
InteractivePremountProps & {
readonly controls?: SequenceControls;
};
@@ -47,6 +47,7 @@ const RenderSvgWithTiming = ({
trimBefore,
trimAfter,
playbackRate,
+ loop,
freeze,
hidden,
showInTimeline,
@@ -84,7 +85,7 @@ const RenderSvgWithTiming = ({
trimBefore,
trimAfter,
playbackRate,
- loop: undefined,
+ loop,
}),
premountFor: premountFor ?? null,
postmountFor: postmountFor ?? null,
@@ -101,6 +102,7 @@ const RenderSvgWithTiming = ({
trimBefore={trimBefore}
trimAfter={trimAfter}
playbackRate={playbackRate}
+ loop={loop}
freeze={freeze}
hidden={hidden}
showInTimeline={showInTimeline}
@@ -145,6 +147,7 @@ export const RenderSvg = ({
trimBefore,
trimAfter,
playbackRate,
+ loop,
freeze,
hidden,
name,
@@ -312,6 +315,7 @@ export const RenderSvg = ({
trimBefore={trimBefore}
trimAfter={trimAfter}
playbackRate={playbackRate}
+ loop={loop}
freeze={freeze}
hidden={hidden}
showInTimeline={showInTimeline}
diff --git a/packages/shapes/src/components/schema.ts b/packages/shapes/src/components/schema.ts
index 40c93a5f7b..c3815821a8 100644
--- a/packages/shapes/src/components/schema.ts
+++ b/packages/shapes/src/components/schema.ts
@@ -85,8 +85,7 @@ export const makeShapeSchema = (
shapeFields: InteractivitySchema,
): InteractivitySchema => {
return {
- // Shapes do not advance with the frame, so a loop control would be inert.
- ...Internals.baseSchemaWithoutLoop,
+ ...Internals.baseSchema,
...Internals.premountSchema,
...shapeFields,
fill: colorField({
diff --git a/packages/shapes/src/test/effects.test.tsx b/packages/shapes/src/test/effects.test.tsx
index ca8c44dac7..70264199b1 100644
--- a/packages/shapes/src/test/effects.test.tsx
+++ b/packages/shapes/src/test/effects.test.tsx
@@ -96,16 +96,6 @@ mock.module('remotion', () => {
name: {},
showInTimeline: {},
},
- baseSchemaWithoutLoop: {
- durationInFrames: {},
- from: {},
- trimBefore: {},
- trimAfter: {},
- freeze: {},
- hidden: {},
- name: {},
- showInTimeline: {},
- },
transformSchema: {},
resolveSequenceDuration: ({
durationInFrames,
diff --git a/packages/shapes/src/test/schema.test.ts b/packages/shapes/src/test/schema.test.ts
index a516ef8814..9701f87726 100644
--- a/packages/shapes/src/test/schema.test.ts
+++ b/packages/shapes/src/test/schema.test.ts
@@ -1,4 +1,5 @@
import {expect, test} from 'bun:test';
+import {Internals} from 'remotion';
import {makeShapeSchema} from '../components/schema';
test('adds a fill control to shape schemas', () => {
@@ -12,4 +13,5 @@ test('adds a fill control to shape schemas', () => {
expect('style.borderWidth' in schema).toBe(true);
expect('style.borderStyle' in schema).toBe(true);
expect('style.borderColor' in schema).toBe(true);
+ expect(schema.loop).toBe(Internals.baseSchema.loop);
});
diff --git a/packages/skills/skills/remotion-interactivity/SKILL.md b/packages/skills/skills/remotion-interactivity/SKILL.md
index 901c49809a..07c00c7d53 100644
--- a/packages/skills/skills/remotion-interactivity/SKILL.md
+++ b/packages/skills/skills/remotion-interactivity/SKILL.md
@@ -305,7 +305,7 @@ Render separate elements if one version should have effects and another should n
## Making your own component interactive
-When using `Interactive.withSchema()`, include `Interactive.baseSchema` in the schema so standard timeline controls such as trimming, looping and visibility remain available, and forward `from`, `durationInFrames`, `trimBefore`, `trimAfter`, `playbackRate`, `loop`, `freeze`, `hidden`, `name` and `showInTimeline` to the `<Sequence>` the component renders. Use `Interactive.baseSchemaWithoutLoop` if the output does not change with the frame.
+When using `Interactive.withSchema()`, include `Interactive.baseSchema` in the schema so standard timeline controls such as trimming, looping and visibility remain available, and forward `from`, `durationInFrames`, `trimBefore`, `trimAfter`, `playbackRate`, `loop`, `freeze`, `hidden`, `name` and `showInTimeline` to the `<Sequence>` the component renders.
To make a custom userland component interactive, use:
[Make a component interactive](https://www.remotion.dev/docs/studio/make-component-interactive.md)
diff --git a/packages/studio/src/components/Timeline/TimelineSequenceRightEdgeDragHandle.tsx b/packages/studio/src/components/Timeline/TimelineSequenceRightEdgeDragHandle.tsx
index 598ccda0ef..bbee8d69d2 100644
--- a/packages/studio/src/components/Timeline/TimelineSequenceRightEdgeDragHandle.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequenceRightEdgeDragHandle.tsx
@@ -437,7 +437,7 @@ export const getTimelineSequenceEndField = ({
typeof trimAfter === 'number' &&
Number.isFinite(trimAfter) &&
(typeof durationInFrames !== 'number' ||
- (trimAfter - trimBefore) / playbackRate <= durationInFrames);
+ (trimAfter - trimBefore) / playbackRate < durationInFrames);
return {
fieldKey: endsAtTrimAfter ? 'trimAfter' : 'durationInFrames',
diff --git a/packages/studio/src/test/timeline-selection.test.ts b/packages/studio/src/test/timeline-selection.test.ts
index 845ad0d9c5..139b666df6 100644
--- a/packages/studio/src/test/timeline-selection.test.ts
+++ b/packages/studio/src/test/timeline-selection.test.ts
@@ -95,6 +95,7 @@ import {
getSequencePropClipboardDataFromSelection,
} from '../components/Timeline/sequence-prop-clipboard';
import {shouldSubscribeToSequenceProps} from '../components/Timeline/should-subscribe-to-sequence-props';
+import {getTimelineSequenceSplitEligibility} from '../components/Timeline/split-selected-timeline-item';
import {parseCssRotationToEuler} from '../components/Timeline/timeline-rotation-utils';
import {
getEasingClipboardDataFromSelection,
@@ -245,6 +246,7 @@ const makeTimelineSequence = ({
showInTimeline = true,
singleChildComponent,
timelineOrder = null,
+ sequencePlaybackRate = 1,
}: {
readonly schema: InteractivitySchema;
readonly effects?: readonly {readonly schema: InteractivitySchema}[];
@@ -265,6 +267,7 @@ const makeTimelineSequence = ({
readonly showInTimeline?: boolean;
readonly singleChildComponent?: unknown;
readonly timelineOrder?: number | null;
+ readonly sequencePlaybackRate?: number;
}): TSequence =>
({
type,
@@ -294,7 +297,7 @@ const makeTimelineSequence = ({
isInsideSeries,
effects,
effectRuntimeValues: null,
- sequencePlaybackRate: 1,
+ sequencePlaybackRate,
frozenFrame: null,
startMediaFrom,
}) as TSequence;
@@ -2007,6 +2010,190 @@ test('Timeline duration drag supports interactive video clips', () => {
]);
});
+test('Timeline edge drags edit the prop that defines the visible end', () => {
+ const nodePathInfo = makeNodePathInfo(['body', 0], []);
+ const nodePath = nodePathInfo.sequenceSubscriptionKey;
+ const makePropStatuses = (
+ fieldKey: 'durationInFrames' | 'trimAfter',
+ ): PropStatuses => ({
+ [Internals.makeSequencePropsSubscriptionKey(nodePath)]: {
+ canUpdate: true,
+ props: {
+ [fieldKey]: {
+ status: 'static',
+ keyframeDisplayOffsetAdjustment: null,
+ codeValue: fieldKey === 'trimAfter' ? 24 : 10,
+ },
+ },
+ effects: [],
+ },
+ });
+ const makeTargets = ({
+ durationInFrames,
+ loop,
+ endField,
+ }: {
+ readonly durationInFrames: number;
+ readonly loop: boolean;
+ readonly endField: 'durationInFrames' | 'trimAfter';
+ }) =>
+ getTimelineSequenceDurationDragTargets({
+ draggedNodePathInfo: nodePathInfo,
+ draggedSequenceMediaDurationDragLimits: null,
+ selectedSequenceMediaDurationDragLimits: null,
+ selectedItems: [{type: 'sequence', nodePathInfo}],
+ sequences: [
+ makeTimelineSequence({
+ schema: Internals.baseSchema,
+ duration: loop ? durationInFrames : Math.min(10, durationInFrames),
+ sequencePlaybackRate: 2,
+ currentRuntimeValueDotNotation: {
+ durationInFrames,
+ loop,
+ playbackRate: 2,
+ trimAfter: 24,
+ trimBefore: 4,
+ },
+ }),
+ ],
+ overrideIdsToNodePaths: {override: nodePath},
+ propStatuses: makePropStatuses(endField),
+ timelineDurationInFrames: 1000,
+ });
+
+ const trimAfterTargets = makeTargets({
+ durationInFrames: 11,
+ loop: false,
+ endField: 'trimAfter',
+ });
+ expect(trimAfterTargets?.[0].endField).toEqual({
+ fieldKey: 'trimAfter',
+ trimBefore: 4,
+ playbackRate: 2,
+ });
+ expect(
+ getTimelineSequenceDurationDragChanges({
+ targets: trimAfterTargets ?? [],
+ deltaFrames: 2,
+ })[0],
+ ).toMatchObject({fieldKey: 'trimAfter', value: 28});
+
+ // If both props end at the same frame, extending trimAfter alone would not
+ // move the edge because durationInFrames would still cap the item.
+ const equalEndTargets = makeTargets({
+ durationInFrames: 10,
+ loop: false,
+ endField: 'durationInFrames',
+ });
+ expect(equalEndTargets?.[0].endField.fieldKey).toBe('durationInFrames');
+ expect(
+ getTimelineSequenceDurationDragChanges({
+ targets: equalEndTargets ?? [],
+ deltaFrames: 2,
+ })[0],
+ ).toMatchObject({fieldKey: 'durationInFrames', value: 12});
+
+ const loopTargets = makeTargets({
+ durationInFrames: 20,
+ loop: true,
+ endField: 'durationInFrames',
+ });
+ expect(loopTargets?.[0].endField.fieldKey).toBe('durationInFrames');
+});
+
+test('Left edge trim leaves duration untouched when trimAfter defines the end', () => {
+ const nodePathInfo = makeNodePathInfo(['body', 0], []);
+ const nodePath = nodePathInfo.sequenceSubscriptionKey;
+ const sequence = makeTimelineSequence({
+ schema: Internals.baseSchema,
+ duration: 10,
+ sequencePlaybackRate: 2,
+ trimBefore: 4,
+ currentRuntimeValueDotNotation: {
+ durationInFrames: 11,
+ playbackRate: 2,
+ trimAfter: 24,
+ trimBefore: 4,
+ },
+ });
+ const targets = getTimelineSequenceLeftEdgeDragTargets({
+ draggedNodePathInfo: nodePathInfo,
+ selectedItems: [{type: 'sequence', nodePathInfo}],
+ sequences: [sequence],
+ overrideIdsToNodePaths: {override: nodePath},
+ propStatuses: makeLeftEdgePropStatuses([nodePath], true),
+ });
+
+ expect(targets?.[0].writesDuration).toBe(false);
+ expect(
+ getTimelineSequenceLeftEdgeDragChanges({
+ targets: targets ?? [],
+ deltaFrames: 2,
+ }).map((change) => [change.fieldKey, change.value]),
+ ).toEqual([
+ ['from', 2],
+ ['trimBefore', 8],
+ ]);
+});
+
+test('Looping timeline items stay resizable but cannot be split', () => {
+ const nodePathInfo = makeNodePathInfo(['body', 0], []);
+ const loopedSequence = {
+ ...makeTimelineSequence({
+ schema: Internals.baseSchema,
+ duration: 20,
+ }),
+ loopDisplay: {
+ durationInFrames: 5,
+ numberOfTimes: 4,
+ startOffset: 0,
+ },
+ } satisfies TSequence;
+ const selection = {
+ type: 'sequence' as const,
+ nodePathInfo,
+ };
+
+ expect(isTimelineSequenceDurationDraggable(loopedSequence)).toBe(true);
+ const loopedVideo = {
+ ...loopedSequence,
+ type: 'video',
+ src: 'video.mp4',
+ volume: 1,
+ doesVolumeChange: false,
+ muted: false,
+ startMediaFrom: 0,
+ mediaFrameAtSequenceZero: 0,
+ playbackRate: 1,
+ frozenMediaFrame: null,
+ } satisfies TSequence;
+ const resizeTargets = getTimelineSequenceDurationDragTargets({
+ draggedNodePathInfo: nodePathInfo,
+ draggedSequenceMediaDurationDragLimits: null,
+ selectedSequenceMediaDurationDragLimits: null,
+ selectedItems: [selection],
+ sequences: [loopedVideo],
+ overrideIdsToNodePaths: {
+ override: nodePathInfo.sequenceSubscriptionKey,
+ },
+ propStatuses: makeDurationPropStatuses([
+ nodePathInfo.sequenceSubscriptionKey,
+ ]),
+ timelineDurationInFrames: 1000,
+ });
+ expect(resizeTargets?.[0]).toMatchObject({
+ initialDuration: 20,
+ maximumDuration: 1000,
+ });
+ expect(
+ getTimelineSequenceSplitEligibility({
+ selection,
+ sequence: loopedSequence,
+ splitFrame: 10,
+ }),
+ ).toEqual({canSplit: false, reason: 'Looping sequences cannot be split'});
+});
+
test('Media duration drag limits account for a negative from', () => {
const common = {
cascadedStart: -192,