Skip to content

🎥 Make videos programmatically with React

Restore timeline dividers and remove clip borders

JonnyBurgerb86be9443633
diff --git a/packages/studio/src/components/Timeline/TimelineExpandedKeyframeRow.tsx b/packages/studio/src/components/Timeline/TimelineExpandedKeyframeRow.tsx
index 088c7a7b70..a89386e2f4 100644
--- a/packages/studio/src/components/Timeline/TimelineExpandedKeyframeRow.tsx
+++ b/packages/studio/src/components/Timeline/TimelineExpandedKeyframeRow.tsx
@@ -1,7 +1,10 @@
import React, {useContext} from 'react';
import {areSequenceNodePathInfosEqual} from '../../helpers/are-sequence-node-path-infos-equal';
import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';
-import {TIMELINE_PADDING} from '../../helpers/timeline-layout';
+import {
+ TIMELINE_ITEM_BORDER_BOTTOM,
+ TIMELINE_PADDING,
+} from '../../helpers/timeline-layout';
import {getTimelineEasingSegments} from './get-timeline-easing-segments';
import type {getTimelineKeyframes} from './get-timeline-keyframes';
import {TimelineKeyframeDiamond} from './TimelineKeyframeDiamond';
@@ -27,16 +30,21 @@ const row: React.CSSProperties = {
position: 'relative',
};
+const rowSeparator: React.CSSProperties = {
+ height: TIMELINE_ITEM_BORDER_BOTTOM,
+};
+
type TimelineExpandedKeyframeRowProps = {
readonly height: number;
readonly keyframes: ReturnType<typeof getTimelineKeyframes>;
readonly canEditEasing: boolean;
readonly nodePathInfo: SequenceNodePathInfo;
+ readonly showSeparator: boolean;
};
const TimelineExpandedKeyframeRowUnmemoized: React.FC<
TimelineExpandedKeyframeRowProps
-> = ({height, keyframes, canEditEasing, nodePathInfo}) => {
+> = ({height, keyframes, canEditEasing, nodePathInfo, showSeparator}) => {
const timelineWidth = useContext(TimelineWidthContext);
const rowHighlightBackground = useTimelineRowHighlightBackground(
nodePathInfo,
@@ -50,36 +58,39 @@ const TimelineExpandedKeyframeRowUnmemoized: React.FC<
: [];
return (
- <div style={{...rowClipper, height, width: timelineWidth ?? undefined}}>
- <div style={{...row, height}}>
- {rowHighlightBackground && timelineWidth !== null ? (
- <div
- style={getTimelineSelectedTrackHighlightStyle(
- timelineWidth,
- rowHighlightBackground,
- )}
- />
- ) : null}
- {easingSegments.map((segment) => (
- <TimelineKeyframeEasingLine
- key={`${segment.segmentIndex}-${segment.fromFrame}-${segment.toFrame}`}
- fromFrame={segment.fromFrame}
- toFrame={segment.toFrame}
- rowHeight={height}
- nodePathInfo={nodePathInfo}
- segmentIndex={segment.segmentIndex}
- />
- ))}
- {keyframes.map((keyframe) => (
- <TimelineKeyframeDiamond
- key={keyframe.frame}
- frame={keyframe.frame}
- rowHeight={height}
- nodePathInfo={nodePathInfo}
- />
- ))}
+ <>
+ {showSeparator ? <div style={rowSeparator} /> : null}
+ <div style={{...rowClipper, height, width: timelineWidth ?? undefined}}>
+ <div style={{...row, height}}>
+ {rowHighlightBackground && timelineWidth !== null ? (
+ <div
+ style={getTimelineSelectedTrackHighlightStyle(
+ timelineWidth,
+ rowHighlightBackground,
+ )}
+ />
+ ) : null}
+ {easingSegments.map((segment) => (
+ <TimelineKeyframeEasingLine
+ key={`${segment.segmentIndex}-${segment.fromFrame}-${segment.toFrame}`}
+ fromFrame={segment.fromFrame}
+ toFrame={segment.toFrame}
+ rowHeight={height}
+ nodePathInfo={nodePathInfo}
+ segmentIndex={segment.segmentIndex}
+ />
+ ))}
+ {keyframes.map((keyframe) => (
+ <TimelineKeyframeDiamond
+ key={keyframe.frame}
+ frame={keyframe.frame}
+ rowHeight={height}
+ nodePathInfo={nodePathInfo}
+ />
+ ))}
+ </div>
</div>
- </div>
+ </>
);
};
@@ -90,6 +101,7 @@ const areTimelineExpandedKeyframeRowPropsEqual = (
if (
prevProps.height !== nextProps.height ||
prevProps.canEditEasing !== nextProps.canEditEasing ||
+ prevProps.showSeparator !== nextProps.showSeparator ||
prevProps.keyframes.length !== nextProps.keyframes.length ||
!areSequenceNodePathInfosEqual(
prevProps.nodePathInfo,
diff --git a/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx b/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx
index 1a1160bab5..847ed13430 100644
--- a/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx
+++ b/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx
@@ -1,11 +1,12 @@
import React, {useMemo} from 'react';
import type {TSequence} from 'remotion';
import type {CodePosition} from '../../error-overlay/react-overlay/utils/get-source-map';
-import {WHITE} from '../../helpers/colors';
+import {TIMELINE_TRACK_SEPARATOR, WHITE} from '../../helpers/colors';
import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';
import {
flattenVisibleTreeNodes,
getTreeRowHeight,
+ TIMELINE_ITEM_BORDER_BOTTOM,
} from '../../helpers/timeline-layout';
import {TimelineExpandedRow} from './TimelineExpandedRow';
import {TimelineRowSelectedBackgroundContext} from './TimelineRowChrome';
@@ -22,7 +23,12 @@ const expandedSectionBase: React.CSSProperties = {
fontSize: 12,
display: 'flex',
flexDirection: 'column',
- position: 'relative',
+ borderBottom: `1px solid ${TIMELINE_TRACK_SEPARATOR}`,
+};
+
+const separator: React.CSSProperties = {
+ height: 0,
+ borderBottom: `1px solid ${TIMELINE_TRACK_SEPARATOR}`,
};
export const TimelineExpandedSection: React.FC<{
@@ -57,13 +63,14 @@ export const TimelineExpandedSection: React.FC<{
(sum, {node}) => sum + getTreeRowHeight(node),
0,
);
- return totalRowsHeight;
+ const separators = Math.max(0, flat.length - 1);
+ return totalRowsHeight + separators;
}, [flat]);
const style = useMemo(() => {
return {
...expandedSectionBase,
- height: expandedHeight,
+ height: expandedHeight + TIMELINE_ITEM_BORDER_BOTTOM,
};
}, [expandedHeight]);
@@ -77,18 +84,11 @@ export const TimelineExpandedSection: React.FC<{
<TimelineRowSelectedBackgroundContext.Provider
value={TIMELINE_EXPANDED_SELECTED_BACKGROUND}
>
- <div style={style} className="remotion-timeline-list-expanded-section">
- {flat.map(({node, depth}, index) => {
+ <div style={style}>
+ {flat.map(({node, depth}, i) => {
return (
- <div
- key={JSON.stringify(node.nodePathInfo)}
- className={
- index < flat.length - 1
- ? 'remotion-timeline-list-row-border'
- : undefined
- }
- style={{height: getTreeRowHeight(node), position: 'relative'}}
- >
+ <React.Fragment key={JSON.stringify(node.nodePathInfo)}>
+ {i > 0 ? <div style={separator} /> : null}
<TimelineExpandedRow
node={node}
depth={depth}
@@ -102,7 +102,7 @@ export const TimelineExpandedSection: React.FC<{
keyframePlaybackRate={keyframePlaybackRate}
keyframeControlsMode="timeline"
/>
- </div>
+ </React.Fragment>
);
})}
</div>
diff --git a/packages/studio/src/components/Timeline/TimelineExpandedTrackKeyframes.tsx b/packages/studio/src/components/Timeline/TimelineExpandedTrackKeyframes.tsx
index ac335d8b4f..b3f3cbd8d0 100644
--- a/packages/studio/src/components/Timeline/TimelineExpandedTrackKeyframes.tsx
+++ b/packages/studio/src/components/Timeline/TimelineExpandedTrackKeyframes.tsx
@@ -24,13 +24,14 @@ const TimelineExpandedTrackKeyframesInner: React.FC<
return (
<div style={{height: expandedHeight}}>
- {rows.map((row) => (
+ {rows.map((row, index) => (
<TimelineExpandedKeyframeRow
key={row.rowKey}
height={row.height}
keyframes={row.keyframes}
canEditEasing={row.canEditEasing}
nodePathInfo={row.nodePathInfo}
+ showSeparator={index > 0}
/>
))}
</div>
diff --git a/packages/studio/src/components/Timeline/TimelineImageInfo.tsx b/packages/studio/src/components/Timeline/TimelineImageInfo.tsx
index 59668ca952..c6c4b5d63e 100644
--- a/packages/studio/src/components/Timeline/TimelineImageInfo.tsx
+++ b/packages/studio/src/components/Timeline/TimelineImageInfo.tsx
@@ -2,7 +2,7 @@ import React, {useMemo} from 'react';
import {BLACK_ALPHA_30} from '../../helpers/colors';
import {getTimelineLayerHeight} from '../../helpers/timeline-layout';
-const HEIGHT = getTimelineLayerHeight('image') - 2;
+const HEIGHT = getTimelineLayerHeight('image');
const containerStyle: React.CSSProperties = {
height: HEIGHT,
diff --git a/packages/studio/src/components/Timeline/TimelineList.tsx b/packages/studio/src/components/Timeline/TimelineList.tsx
index 8c1d2ef152..4d85afaa7f 100644
--- a/packages/studio/src/components/Timeline/TimelineList.tsx
+++ b/packages/studio/src/components/Timeline/TimelineList.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import {BACKGROUND, TIMELINE_TRACK_SEPARATOR} from '../../helpers/colors';
+import {BACKGROUND} from '../../helpers/colors';
import {TimelineSequenceItem} from './TimelineSequenceItem';
import {
type TimelineVirtualRow,
@@ -48,24 +48,7 @@ export const TimelineList: React.FC = () => {
return (
<div style={{...container, height: tracksEnd}}>
- <style>{`.remotion-timeline-list-row-border::after,
- .remotion-timeline-list-expanded-section::before {
- content: '';
- position: absolute;
- left: 0;
- right: 0;
- height: 0;
- border-bottom: 1px solid ${TIMELINE_TRACK_SEPARATOR};
- pointer-events: none;
- z-index: 1;
- }
- .remotion-timeline-list-row-border::after {
- bottom: 0;
- }
- .remotion-timeline-list-expanded-section::before {
- top: 0;
- }
- .remotion-timeline-sequence-name-measure::before {
+ <style>{`.remotion-timeline-sequence-name-measure::before {
content: attr(data-name);
display: block;
font-family: Arial, Helvetica, sans-serif;
@@ -76,7 +59,6 @@ export const TimelineList: React.FC = () => {
{virtualItems.map((virtualItem) => (
<div
key={virtualItem.key}
- className="remotion-timeline-list-row-border"
style={{
height: virtualItem.size,
left: 0,
diff --git a/packages/studio/src/components/Timeline/TimelineRowChrome.tsx b/packages/studio/src/components/Timeline/TimelineRowChrome.tsx
index 4ecb3c7dfb..f2aae9b593 100644
--- a/packages/studio/src/components/Timeline/TimelineRowChrome.tsx
+++ b/packages/studio/src/components/Timeline/TimelineRowChrome.tsx
@@ -1,4 +1,5 @@
import React, {useCallback, useContext, useMemo} from 'react';
+import {TIMELINE_TRACK_SEPARATOR} from '../../helpers/colors';
import {createDragAwareDoubleClickTracker} from '../../helpers/drag-aware-double-click';
import {Padder} from './Padder';
import {
@@ -72,8 +73,9 @@ export const TimelineRowChrome: React.FC<{
readonly showSelectedBackground: boolean;
readonly containsSelection: boolean;
readonly hovered?: boolean;
- // When set, the chrome is wrapped in an outer container of this height. The
- // highlight and click target span the full layer, including taller media rows.
+ // When set, the chrome is wrapped in an outer container of this height with a
+ // bottom track separator. The background highlight and click target span the
+ // outer (used by sequence rows whose layer is taller than the chrome row).
readonly outerHeight: number | null;
readonly onDragLeave?: (e: React.DragEvent<HTMLDivElement>) => void;
readonly onDragOver?: (e: React.DragEvent<HTMLDivElement>) => void;
@@ -208,6 +210,7 @@ export const TimelineRowChrome: React.FC<{
return {
height: outerHeight,
+ borderBottom: `1px solid ${TIMELINE_TRACK_SEPARATOR}`,
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsx
index 98b7fc544e..4334c4df30 100644
--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx
@@ -28,10 +28,7 @@ import {
getConnectedCompositionFrame,
getSequenceDoubleClickAction,
} from '../../helpers/get-sequence-double-click-action';
-import {
- getTimelineSequenceLayout,
- SEQUENCE_BORDER_WIDTH,
-} from '../../helpers/get-timeline-sequence-layout';
+import {getTimelineSequenceLayout} from '../../helpers/get-timeline-sequence-layout';
import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';
import {isStudioInteractivityEnabled} from '../../helpers/interactivity-enabled';
import {isVideoWithLastFrameHold} from '../../helpers/is-video-with-last-frame-hold';
@@ -95,7 +92,7 @@ import {useOpenSequenceInApps} from './use-open-sequence-in-apps';
import {getSequenceFreezeFrameMenuItem} from './use-sequence-freeze-frame-menu-item';
const {getTimelineVisibleDuration, getTimelineVisibleStart} = CanvasInternals;
-const TIMELINE_SEQUENCE_BORDER_COLOR = '#151515';
+const NEGATIVE_START_BORDER_WIDTH = 1;
const EDGE_DRAG_HIGHLIGHT_WIDTH = 12;
const TimelineSequenceFn: React.FC<{
@@ -159,10 +156,10 @@ const TimelineSequenceNegativeStartInner: React.FC<{
return {
backgroundColor: TIMELINE_NEGATIVE_START_BACKGROUND_COLOR,
- border: `${SEQUENCE_BORDER_WIDTH}px solid ${TIMELINE_NEGATIVE_START_BORDER_COLOR}`,
+ border: `${NEGATIVE_START_BORDER_WIDTH}px solid ${TIMELINE_NEGATIVE_START_BORDER_COLOR}`,
borderBottomLeftRadius: showLeftEdge ? 2 : 0,
borderLeft: showLeftEdge
- ? `${SEQUENCE_BORDER_WIDTH}px solid ${TIMELINE_NEGATIVE_START_BORDER_COLOR}`
+ ? `${NEGATIVE_START_BORDER_WIDTH}px solid ${TIMELINE_NEGATIVE_START_BORDER_COLOR}`
: 'none',
borderRight: 'none',
borderTopLeftRadius: showLeftEdge ? 2 : 0,
@@ -296,7 +293,6 @@ const TimelineSequenceCurrentFrame: React.FC<{
return {
...style,
background: negativeStart ? TRANSPARENT : sequenceBackground,
- border: negativeStart ? 'none' : style.border,
opacity:
activeTrimEdge !== null || selected || containsSelection || isAsset
? 1
@@ -414,11 +410,8 @@ const TimelineSequenceCurrentFrame: React.FC<{
<div
style={{
background: sequenceBackground,
- border: style.border,
borderBottomLeftRadius: 0,
borderBottomRightRadius: style.borderBottomRightRadius,
- borderLeft: 'none',
- borderRightColor: style.borderRightColor,
borderTopLeftRadius: 0,
borderTopRightRadius: style.borderTopRightRadius,
boxSizing: 'border-box',
@@ -1083,14 +1076,6 @@ const TimelineSequenceInner: React.FC<{
: s.type === 'video'
? TIMELINE_VIDEO_GRADIENT
: BLUE,
- border: `${SEQUENCE_BORDER_WIDTH}px solid ${TIMELINE_SEQUENCE_BORDER_COLOR}`,
- borderLeftColor:
- visibleLayout?.leftEdgeVisible && !negativeStartClipped
- ? TIMELINE_SEQUENCE_BORDER_COLOR
- : TRANSPARENT,
- borderRightColor: visibleLayout?.rightEdgeVisible
- ? TIMELINE_SEQUENCE_BORDER_COLOR
- : TRANSPARENT,
borderTopLeftRadius: showLeftBorderRadius ? 2 : 0,
borderBottomLeftRadius: showLeftBorderRadius ? 2 : 0,
borderTopRightRadius: showRightBorderRadius ? 2 : 0,
@@ -1103,13 +1088,7 @@ const TimelineSequenceInner: React.FC<{
// Edge handles extend outside the layer; media is clipped separately.
overflow: 'visible',
};
- }, [
- negativeStartClipped,
- s.type,
- showLeftBorderRadius,
- showRightBorderRadius,
- visibleLayout,
- ]);
+ }, [s.type, showLeftBorderRadius, showRightBorderRadius, visibleLayout]);
const showRightEdgeDragHandle =
isTimelineSequenceDurationDraggable(s) &&
diff --git a/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx b/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
index e229f99f57..70f2e3f0b7 100644
--- a/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
@@ -39,6 +39,7 @@ import {
import {getStudioKeyboardShortcutsEnabled} from '../../helpers/studio-runtime-config';
import {
getTimelineLayerHeight,
+ TIMELINE_ITEM_BORDER_BOTTOM,
TIMELINE_LIST_ITEM_ROW_HEIGHT,
} from '../../helpers/timeline-layout';
import {useKeybinding} from '../../helpers/use-keybinding';
@@ -984,7 +985,7 @@ const TimelineSequenceItemInner: React.FC<{
);
const outerHeight = useMemo(
- () => getTimelineLayerHeight(sequence.type),
+ () => getTimelineLayerHeight(sequence.type) + TIMELINE_ITEM_BORDER_BOTTOM,
[sequence.type],
);
diff --git a/packages/studio/src/components/Timeline/TimelineTimeIndicators.tsx b/packages/studio/src/components/Timeline/TimelineTimeIndicators.tsx
index c86775be4c..949d640309 100644
--- a/packages/studio/src/components/Timeline/TimelineTimeIndicators.tsx
+++ b/packages/studio/src/components/Timeline/TimelineTimeIndicators.tsx
@@ -8,7 +8,10 @@ import {
} from '../../helpers/colors';
import {resolveStudioColor} from '../../helpers/resolve-studio-color';
import {getStudioPixelRatio} from '../../helpers/studio-pixel-ratio';
-import {TIMELINE_PADDING} from '../../helpers/timeline-layout';
+import {
+ TIMELINE_ITEM_BORDER_BOTTOM,
+ TIMELINE_PADDING,
+} from '../../helpers/timeline-layout';
import {renderFrame} from '../../state/render-frame';
import {TimeValue} from '../TimeValue';
import {scrollableRef} from './timeline-refs';
@@ -24,7 +27,7 @@ const container: React.CSSProperties = {
position: 'absolute',
backgroundColor: TIMELINE_TICKS_BACKGROUND,
top: 0,
- borderBottom: `1px solid ${TIMELINE_TRACK_SEPARATOR}`,
+ borderBottom: `${TIMELINE_ITEM_BORDER_BOTTOM}px solid ${TIMELINE_TRACK_SEPARATOR}`,
};
const TICK_LABEL_FONT_SIZE = 12;
@@ -44,7 +47,7 @@ const timeValue: React.CSSProperties = {
display: 'flex',
alignItems: 'center',
backgroundColor: BACKGROUND,
- borderBottom: `1px solid ${TIMELINE_TRACK_SEPARATOR}`,
+ borderBottom: `${TIMELINE_ITEM_BORDER_BOTTOM}px solid ${TIMELINE_TRACK_SEPARATOR}`,
};
export const TimelineTimePlaceholders: React.FC = () => {
diff --git a/packages/studio/src/components/Timeline/TimelineTrack.tsx b/packages/studio/src/components/Timeline/TimelineTrack.tsx
index 3c80f0726f..24d8401ccd 100644
--- a/packages/studio/src/components/Timeline/TimelineTrack.tsx
+++ b/packages/studio/src/components/Timeline/TimelineTrack.tsx
@@ -1,7 +1,10 @@
import React, {useContext, useMemo} from 'react';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
import type {TimelineTrackData} from '../../helpers/get-timeline-sequence-sort-key';
-import {getTimelineLayerHeight} from '../../helpers/timeline-layout';
+import {
+ getTimelineLayerHeight,
+ TIMELINE_ITEM_BORDER_BOTTOM,
+} from '../../helpers/timeline-layout';
import {useTimelineSequenceHover} from '../../state/timeline-sequence-hover';
import {ExpandedTracksGetterContext} from '../ExpandedTracksProvider';
import {TimelineExpandedTrackKeyframes} from './TimelineExpandedTrackKeyframes';
@@ -36,6 +39,7 @@ const TimelineTrackUnmemoized: React.FC<{
const layerStyle = useMemo(
(): React.CSSProperties => ({
height: getTimelineLayerHeight(track.sequence.type),
+ marginBottom: TIMELINE_ITEM_BORDER_BOTTOM,
position: 'relative',
}),
[track.sequence.type],
diff --git a/packages/studio/src/components/Timeline/TimelineVirtualization.tsx b/packages/studio/src/components/Timeline/TimelineVirtualization.tsx
index 24b49ffad5..5f4e4941eb 100644
--- a/packages/studio/src/components/Timeline/TimelineVirtualization.tsx
+++ b/packages/studio/src/components/Timeline/TimelineVirtualization.tsx
@@ -13,6 +13,7 @@ import React, {
useMemo,
useRef,
} from 'react';
+import {TIMELINE_ITEM_BORDER_BOTTOM} from '../../helpers/timeline-layout';
import {MAX_TIMELINE_TRACKS_NOTICE_HEIGHT} from './MaxTimelineTracks';
import type {TimelineTrackWithDisplayGroup} from './timeline-display-groups';
import {timelineVerticalScroll} from './timeline-refs';
@@ -57,7 +58,9 @@ export const TimelineVirtualizationProvider: React.FC<{
const trackHeights = useTimelineTrackHeights({timeline});
const {revealRequest, selectedItems} = useTimelineSelection();
const paddingStart = isStill ? 0 : TIMELINE_TIME_INDICATOR_HEIGHT;
- const paddingEnd = hasBeenCut ? MAX_TIMELINE_TRACKS_NOTICE_HEIGHT : 0;
+ const paddingEnd =
+ TIMELINE_ITEM_BORDER_BOTTOM +
+ (hasBeenCut ? MAX_TIMELINE_TRACKS_NOTICE_HEIGHT : 0);
const layout = useMemo(() => {
const siblingIndexes = new Array<number>(timeline.length);
diff --git a/packages/studio/src/components/Timeline/use-expanded-track-keyframe-rows.ts b/packages/studio/src/components/Timeline/use-expanded-track-keyframe-rows.ts
index 6ba83a172b..52a8bcca5a 100644
--- a/packages/studio/src/components/Timeline/use-expanded-track-keyframe-rows.ts
+++ b/packages/studio/src/components/Timeline/use-expanded-track-keyframe-rows.ts
@@ -205,7 +205,8 @@ export const useExpandedTrackKeyframeRows = ({
(sum, {node}) => sum + getTreeRowHeight(node),
0,
);
- return totalRowsHeight;
+ const separators = Math.max(0, flat.length - 1);
+ return totalRowsHeight + separators;
}, [flat]);
const nodeKeyframes = useMemo(
diff --git a/packages/studio/src/components/Timeline/use-timeline-height.ts b/packages/studio/src/components/Timeline/use-timeline-height.ts
index c49e799b8a..e7c93556a8 100644
--- a/packages/studio/src/components/Timeline/use-timeline-height.ts
+++ b/packages/studio/src/components/Timeline/use-timeline-height.ts
@@ -7,6 +7,7 @@ import {
flattenVisibleTreeNodes,
getTimelineLayerHeight,
getTreeRowHeight,
+ TIMELINE_ITEM_BORDER_BOTTOM,
} from '../../helpers/timeline-layout';
import {useRuntimeValueSnapshots} from '../../helpers/use-runtime-values';
import {ExpandedTracksGetterContext} from '../ExpandedTracksProvider';
@@ -70,7 +71,9 @@ export const useTimelineTrackHeights = ({
previewServerConnected &&
track.nodePathInfo !== null &&
getIsExpanded(track.nodePathInfo);
- const layerHeight = getTimelineLayerHeight(track.sequence.type);
+ const layerHeight =
+ getTimelineLayerHeight(track.sequence.type) +
+ TIMELINE_ITEM_BORDER_BOTTOM;
const expandedHeight = (() => {
if (!isExpanded || track.nodePathInfo === null) {
return 0;
@@ -119,7 +122,8 @@ export const useTimelineTrackHeights = ({
(sum, {node}) => sum + getTreeRowHeight(node),
0,
);
- return totalRowsHeight;
+ const separators = Math.max(0, flat.length - 1);
+ return totalRowsHeight + separators + TIMELINE_ITEM_BORDER_BOTTOM;
})();
return layerHeight + expandedHeight;
});
diff --git a/packages/studio/src/helpers/get-timeline-sequence-layout.ts b/packages/studio/src/helpers/get-timeline-sequence-layout.ts
index 98120a9a79..c6747ebe6f 100644
--- a/packages/studio/src/helpers/get-timeline-sequence-layout.ts
+++ b/packages/studio/src/helpers/get-timeline-sequence-layout.ts
@@ -1,8 +1,6 @@
import type {VideoConfig} from 'remotion';
import {TIMELINE_PADDING} from './timeline-layout';
-export const SEQUENCE_BORDER_WIDTH = 1;
-
const getWidthOfTrack = ({
durationInFrames,
timelineDuration,
@@ -22,7 +20,7 @@ const getWidthOfTrack = ({
? fullWidth
: (spatialDuration / timelineDuration) * fullWidth;
- return Math.max(0, base - SEQUENCE_BORDER_WIDTH + nonNegativeMarginLeft);
+ return Math.max(0, base + nonNegativeMarginLeft);
};
export const getTimelineSequenceLayout = ({
diff --git a/packages/studio/src/helpers/timeline-layout.ts b/packages/studio/src/helpers/timeline-layout.ts
index 98da96a6d6..78a146592f 100644
--- a/packages/studio/src/helpers/timeline-layout.ts
+++ b/packages/studio/src/helpers/timeline-layout.ts
@@ -43,6 +43,7 @@ export type {
export const TIMELINE_PADDING = 16;
export const TIMELINE_BORDER = 1;
+export const TIMELINE_ITEM_BORDER_BOTTOM = 1;
export const TIMELINE_TRACK_EXPANDED_HEIGHT = 100;
@@ -278,19 +279,20 @@ export const getExpandedTrackHeight = ({
(sum, {node}) => sum + getTreeRowHeight(node),
0,
);
- return totalRowsHeight;
+ const separators = Math.max(0, flat.length - 1);
+ return totalRowsHeight + separators;
};
export const TIMELINE_LAYER_FILMSTRIP_HEIGHT = 26;
// The waveform stripe rendered underneath the filmstrip in TimelineVideoInfo.
-export const TIMELINE_VIDEO_INFO_WAVEFORM_HEIGHT = 18;
+export const TIMELINE_VIDEO_INFO_WAVEFORM_HEIGHT = 19;
export const TIMELINE_LAYER_HEIGHT_VIDEO =
- 2 + TIMELINE_LAYER_FILMSTRIP_HEIGHT + TIMELINE_VIDEO_INFO_WAVEFORM_HEIGHT;
+ TIMELINE_LAYER_FILMSTRIP_HEIGHT + TIMELINE_VIDEO_INFO_WAVEFORM_HEIGHT;
-export const TIMELINE_LAYER_HEIGHT_AUDIO = 35;
-export const TIMELINE_LAYER_HEIGHT_DEFAULT = 22;
+export const TIMELINE_LAYER_HEIGHT_AUDIO = 34;
+export const TIMELINE_LAYER_HEIGHT_DEFAULT = 21;
// The horizontal row inside a timeline list item (eye + arrow + label).
-export const TIMELINE_LIST_ITEM_ROW_HEIGHT = 22;
+export const TIMELINE_LIST_ITEM_ROW_HEIGHT = 21;
export const getTimelineLayerHeight = (
type: 'video' | 'image' | 'audio' | 'sequence' | 'other',
diff --git a/packages/studio/src/test/timeline-sequence-layout.test.ts b/packages/studio/src/test/timeline-sequence-layout.test.ts
index 2b16f0a1af..81d6dfaa4d 100644
--- a/packages/studio/src/test/timeline-sequence-layout.test.ts
+++ b/packages/studio/src/test/timeline-sequence-layout.test.ts
@@ -1,9 +1,6 @@
import {expect, test} from 'bun:test';
import type {VideoConfig} from 'remotion';
-import {
- SEQUENCE_BORDER_WIDTH,
- getTimelineSequenceLayout,
-} from '../helpers/get-timeline-sequence-layout';
+import {getTimelineSequenceLayout} from '../helpers/get-timeline-sequence-layout';
const makeVideoConfig = (durationInFrames: number): VideoConfig => ({
durationInFrames,
@@ -48,8 +45,8 @@ test('Should test timeline sequence layout without max media duration', () => {
postmountWidth: null,
negativeStartWidth: 0,
negativeStartClipped: false,
- width: 227.18045810978126,
- naturalWidth: 227.18045810978126,
+ width: 228.18045810978126,
+ naturalWidth: 228.18045810978126,
});
});
test('Should test timeline sequence layout with max media duration', () => {
@@ -84,8 +81,8 @@ test('Should test timeline sequence layout with max media duration', () => {
postmountWidth: null,
negativeStartWidth: 0,
negativeStartClipped: false,
- width: 221.47594665703676,
- naturalWidth: 221.47594665703676,
+ width: 222.47594665703676,
+ naturalWidth: 222.47594665703676,
});
});
@@ -138,8 +135,8 @@ test('one-frame segments have a one-frame width', () => {
windowWidth: 1000,
});
- expect(result.width).toBe(2.226666666666667);
- expect(result.naturalWidth).toBe(2.226666666666667);
+ expect(result.width).toBe(3.226666666666667);
+ expect(result.naturalWidth).toBe(3.226666666666667);
});
test('adjacent sequences have no visual gap', () => {
@@ -166,9 +163,7 @@ test('adjacent sequences have no visual gap', () => {
windowWidth: 1000,
});
- expect(first.marginLeft + first.width + SEQUENCE_BORDER_WIDTH).toBe(
- second.marginLeft,
- );
+ expect(first.marginLeft + first.width).toBe(second.marginLeft);
});
test('media trimmed past its duration has zero width', () => {
@@ -290,7 +285,7 @@ test('negative starts use the left timeline gutter without shifting frame zero',
expect(oneFrameBeforeZero.marginLeft).toBe(-10);
expect(oneFrameBeforeZero.negativeStartWidth).toBe(10);
expect(oneFrameBeforeZero.negativeStartClipped).toBe(false);
- expect(oneFrameBeforeZero.width).toBe(999);
+ expect(oneFrameBeforeZero.width).toBe(1000);
const clippedToGutter = getTimelineSequenceLayout({
durationInFrames: 80,