Create polished demo videos without editing skills. Mac/Windows/Linux
fix(timeline): stretch visible rows without capping panel
webadderallce69a2afc5bd
diff --git a/src/components/video-editor/VideoEditor.tsx b/src/components/video-editor/VideoEditor.tsxindex e95372c2..580627ac 100644--- a/src/components/video-editor/VideoEditor.tsx+++ b/src/components/video-editor/VideoEditor.tsx@@ -124,7 +124,6 @@ import {RECORDLY_ISSUES_URL,} from "./TutorialHelp";import TimelineEditor, { type TimelineEditorHandle } from "./timeline/TimelineEditor";-import { TIMELINE_VIEWPORT_MIN_HEIGHT_PX } from "./timeline/timelineLayout";import { normalizeCursorTelemetry } from "./timeline/zoomSuggestionUtils";import {type AnnotationRegion,@@ -5699,9 +5698,8 @@ export default function VideoEditor() {<divclassName="flex-shrink-0 flex flex-col"style={{- height: timelineCollapsed ? undefined : TIMELINE_VIEWPORT_MIN_HEIGHT_PX,- minHeight: timelineCollapsed ? 0 : TIMELINE_VIEWPORT_MIN_HEIGHT_PX,- maxHeight: timelineCollapsed ? undefined : TIMELINE_VIEWPORT_MIN_HEIGHT_PX,+ height: timelineCollapsed ? undefined : "15%",+ minHeight: timelineCollapsed ? 0 : 160,}}><TimelineEditordiff --git a/src/components/video-editor/timeline/TimelineEditor.tsx b/src/components/video-editor/timeline/TimelineEditor.tsxindex fe92bce9..ee3c314d 100644--- a/src/components/video-editor/timeline/TimelineEditor.tsx+++ b/src/components/video-editor/timeline/TimelineEditor.tsx@@ -63,6 +63,8 @@ import TimelineWrapper from "./TimelineWrapper";import {getTimelineContentMinHeightPx,getTimelineRowsMinHeightPx,+ getTimelineViewportStretchFactor,+ TIMELINE_AXIS_HEIGHT_PX,} from "./timelineLayout";import { type AudioPeaksData, useAudioPeaks } from "./useAudioPeaks";import { buildInteractionZoomSuggestions } from "./zoomSuggestionUtils";@@ -709,13 +711,14 @@ function Timeline({const timelineRowCount = 2 + annotationRowIds.length + audioRowIds.length;const timelineRowsMinHeightPx = getTimelineRowsMinHeightPx(timelineRowCount);const timelineContentMinHeightPx = getTimelineContentMinHeightPx(timelineRowCount);+ const timelineViewportStretchFactor = getTimelineViewportStretchFactor(timelineRowCount);return (<divref={setRefs}style={{...style,- minHeight: `max(100%, ${timelineContentMinHeightPx}px)`,+ minHeight: `max(100%, ${timelineContentMinHeightPx}px, calc(${TIMELINE_AXIS_HEIGHT_PX}px + (100% - ${TIMELINE_AXIS_HEIGHT_PX}px) * ${timelineViewportStretchFactor}))`,}}className="select-none bg-editor-bg relative cursor-pointer group flex flex-col"onClick={handleTimelineClick}diff --git a/src/components/video-editor/timeline/timelineLayout.test.ts b/src/components/video-editor/timeline/timelineLayout.test.tsindex 3e880dbd..38c26138 100644--- a/src/components/video-editor/timeline/timelineLayout.test.ts+++ b/src/components/video-editor/timeline/timelineLayout.test.ts@@ -2,9 +2,9 @@ import { describe, expect, it } from "vitest";import {getTimelineContentMinHeightPx,getTimelineRowsMinHeightPx,+ getTimelineViewportStretchFactor,TIMELINE_AXIS_HEIGHT_PX,TIMELINE_ROW_MIN_HEIGHT_PX,- TIMELINE_VIEWPORT_MIN_HEIGHT_PX,TIMELINE_VISIBLE_ROW_COUNT,} from "./timelineLayout";@@ -33,8 +33,9 @@ describe("timelineLayout", () => {it("caps the default timeline viewport to two visible rows", () => {expect(TIMELINE_VISIBLE_ROW_COUNT).toBe(2);- expect(TIMELINE_VIEWPORT_MIN_HEIGHT_PX).toBe(- TIMELINE_AXIS_HEIGHT_PX + TIMELINE_VISIBLE_ROW_COUNT * TIMELINE_ROW_MIN_HEIGHT_PX,- );+ expect(getTimelineViewportStretchFactor(2)).toBe(1);+ expect(getTimelineViewportStretchFactor(4)).toBe(2);+ expect(getTimelineViewportStretchFactor(5)).toBe(2.5);+ expect(getTimelineViewportStretchFactor(0)).toBe(1);});});diff --git a/src/components/video-editor/timeline/timelineLayout.ts b/src/components/video-editor/timeline/timelineLayout.tsindex 072b64d3..0f54c4b4 100644--- a/src/components/video-editor/timeline/timelineLayout.ts+++ b/src/components/video-editor/timeline/timelineLayout.ts@@ -18,6 +18,12 @@ export function getTimelineContentMinHeightPx(rowCount: number) {return TIMELINE_AXIS_HEIGHT_PX + getTimelineRowsMinHeightPx(rowCount);}-export const TIMELINE_VIEWPORT_MIN_HEIGHT_PX = getTimelineContentMinHeightPx(- TIMELINE_VISIBLE_ROW_COUNT,-);+export function getTimelineViewportStretchFactor(rowCount: number) {+ const normalizedRowCount = normalizeRowCount(rowCount);++ if (normalizedRowCount <= 0) {+ return 1;+ }++ return Math.max(1, normalizedRowCount / TIMELINE_VISIBLE_ROW_COUNT);+}