Skip to content

🎥 Make videos programmatically with React

Align child transition cutoffs across different row heights

JonnyBurgerf8b7ff6c996e
diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsx
index a4ad51eba2..b76e56ecfa 100644
--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx
@@ -76,6 +76,7 @@ import {getTimelineMediaStartFrame} from './get-timeline-media-start-frame';
import {
getTimelineSceneClipPath,
getTimelineSceneShape,
+ TIMELINE_CHILD_TRANSITION_SEAM_Y,
} from './get-timeline-scene-clip-path';
import {getTimelineSequenceVisibleLayout} from './get-timeline-sequence-visible-layout';
import {getCurrentFrame} from './imperative-state';
@@ -556,7 +557,10 @@ const TimelineSequenceBar: React.FC<{
s.timelineTrack?.role === 'clip'
? Number(style.height)
: (sceneClipHeight ?? Number(style.height)),
- seamFraction: s.timelineTrack?.role === 'clip' ? 0.5 : 0.3,
+ seamY:
+ s.timelineTrack?.role === 'clip'
+ ? Number(style.height) / 2
+ : TIMELINE_CHILD_TRANSITION_SEAM_Y,
cropHeight: Number(style.height),
});
}, [
@@ -586,7 +590,10 @@ const TimelineSequenceBar: React.FC<{
s.timelineTrack?.role === 'clip'
? Number(style.height)
: (sceneClipHeight ?? Number(style.height)),
- seamFraction: s.timelineTrack?.role === 'clip' ? 0.5 : 0.3,
+ seamY:
+ s.timelineTrack?.role === 'clip'
+ ? Number(style.height) / 2
+ : TIMELINE_CHILD_TRANSITION_SEAM_Y,
cropHeight: Number(style.height),
});
}, [
@@ -621,7 +628,7 @@ const TimelineSequenceBar: React.FC<{
durationInFrames: Number(style.width) / frameIncrement,
pixelsPerFrame: frameIncrement,
height: Number(style.height),
- seamFraction: 0.5,
+ seamY: Number(style.height) / 2,
cropHeight: null,
})
: undefined,
diff --git a/packages/studio/src/components/Timeline/TimelineTracks.tsx b/packages/studio/src/components/Timeline/TimelineTracks.tsx
index e4edb2062e..06945b6eec 100644
--- a/packages/studio/src/components/Timeline/TimelineTracks.tsx
+++ b/packages/studio/src/components/Timeline/TimelineTracks.tsx
@@ -1,7 +1,10 @@
import React, {useContext, useImperativeHandle, useMemo} from 'react';
import {Internals} from 'remotion';
import {TIMELINE_PADDING} from '../../helpers/timeline-layout';
-import {getTimelineSceneClipPath} from './get-timeline-scene-clip-path';
+import {
+ getTimelineSceneClipPath,
+ TIMELINE_CHILD_TRANSITION_SEAM_Y,
+} from './get-timeline-scene-clip-path';
import {MaxTimelineTracksReached} from './MaxTimelineTracks';
import {timelineDurationRef, timelineLayerLayoutsRef} from './timeline-refs';
import type {TimelineSceneRange} from './timeline-series-layout';
@@ -141,7 +144,7 @@ const TimelineTracksInner: React.FC<{
(windowWidth - TIMELINE_PADDING * 2) /
video.durationInFrames,
height: virtualItem.size,
- seamFraction: 0.3,
+ seamY: TIMELINE_CHILD_TRANSITION_SEAM_Y,
cropHeight: null,
})
: undefined,
diff --git a/packages/studio/src/components/Timeline/get-timeline-scene-clip-path.ts b/packages/studio/src/components/Timeline/get-timeline-scene-clip-path.ts
index c08213d133..6651d8caaa 100644
--- a/packages/studio/src/components/Timeline/get-timeline-scene-clip-path.ts
+++ b/packages/studio/src/components/Timeline/get-timeline-scene-clip-path.ts
@@ -1,12 +1,15 @@
import type {TimelineSceneRange} from './timeline-series-layout';
+// Child rows can have different media heights, but their seams must meet.
+export const TIMELINE_CHILD_TRANSITION_SEAM_Y = 7;
+
type TimelineSceneClipOptions = {
readonly sceneRange: TimelineSceneRange | null;
readonly durationInFrames: number;
readonly offsetInFrames: number;
readonly pixelsPerFrame: number;
readonly height: number;
- readonly seamFraction: number;
+ readonly seamY: number;
readonly cropHeight: number | null;
};
@@ -16,7 +19,7 @@ export const getTimelineSceneShape = ({
offsetInFrames,
pixelsPerFrame,
height,
- seamFraction,
+ seamY,
cropHeight,
}: TimelineSceneClipOptions): {
readonly clipPath: string;
@@ -41,7 +44,7 @@ export const getTimelineSceneShape = ({
};
}
- const middle = (Math.round(height * seamFraction) / height) * 100;
+ const middle = (Math.min(height, Math.round(seamY)) / height) * 100;
const outgoingInset =
sceneRange.transitionOutStart === null ? 0 : 1 / pixelsPerFrame;
const outgoingMiddle =