Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(editor): auto-expand timeline height on track addition

Richie McIlroy96c7a78d67b8
diff --git a/apps/desktop/src/routes/editor/Editor.tsx b/apps/desktop/src/routes/editor/Editor.tsx
index ddf85cb5c..3f706fae8 100644
--- a/apps/desktop/src/routes/editor/Editor.tsx
+++ b/apps/desktop/src/routes/editor/Editor.tsx
@@ -275,6 +275,10 @@ function Inner() {
{ name: "editorTimelineHeight" },
);
const [isResizingTimeline, setIsResizingTimeline] = createSignal(false);
+ const [timelineViewportOverflow, setTimelineViewportOverflow] = createSignal<{
+ overflow: number;
+ visibleTrackCount: number;
+ } | null>(null);
const clampTimelineHeight = (value: number) => {
const available = layoutBounds.height ?? 0;
@@ -320,6 +324,23 @@ function Inner() {
setStoredTimelineHeight((height) => clampTimelineHeight(height));
});
+ createEffect(
+ on(timelineViewportOverflow, (next, prev) => {
+ if (
+ next &&
+ prev &&
+ next.visibleTrackCount > prev.visibleTrackCount &&
+ next.overflow > 0
+ ) {
+ setStoredTimelineHeight((height) =>
+ clampTimelineHeight(height + next.overflow),
+ );
+ }
+
+ return next;
+ }),
+ );
+
createTauriEventListener(events.editorStateChanged, (payload) => {
throttledRenderFrame.clear();
trailingRenderFrame.clear();
@@ -463,7 +484,9 @@ function Inner() {
style={{ height: `${timelineHeight()}px` }}
>
<div class="h-full">
- <Timeline />
+ <Timeline
+ onViewportOverflowChange={setTimelineViewportOverflow}
+ />
</div>
</div>
</div>