From d750d7f41dfdb8e3c9a2b00206657ca0c4b99098 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Tue, 8 Jul 2025 00:07:22 +0200 Subject: shipping too hard --- apps/web/src/components/editor/timeline.tsx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'apps/web/src/components/editor/timeline.tsx') diff --git a/apps/web/src/components/editor/timeline.tsx b/apps/web/src/components/editor/timeline.tsx index 6a94ed60..f7208224 100644 --- a/apps/web/src/components/editor/timeline.tsx +++ b/apps/web/src/components/editor/timeline.tsx @@ -46,6 +46,9 @@ import { TimelineTrackContent } from "./timeline-track"; import type { DragData } from "@/types/timeline"; import { getTrackLabelColor, + getTrackHeight, + getCumulativeHeightBefore, + getTotalTracksHeight, TIMELINE_CONSTANTS, } from "@/lib/timeline-constants"; @@ -242,9 +245,9 @@ export function Timeline() { track.elements.forEach((element) => { const clipLeft = element.startTime * TIMELINE_CONSTANTS.PIXELS_PER_SECOND * zoomLevel; - const clipTop = trackIdx * TIMELINE_CONSTANTS.TRACK_HEIGHT; - const clipBottom = clipTop + TIMELINE_CONSTANTS.TRACK_HEIGHT; - const clipRight = clipLeft + TIMELINE_CONSTANTS.TRACK_HEIGHT; + const clipTop = getCumulativeHeightBefore(tracks, trackIdx); + const clipBottom = clipTop + getTrackHeight(track.type); + const clipRight = clipLeft + getTrackHeight(track.type); if ( bx1 < clipRight && bx2 > clipLeft && @@ -1021,7 +1024,8 @@ export function Timeline() { {tracks.map((track) => (
{ // If clicking empty area (not on a element), deselect all elements @@ -1098,7 +1102,7 @@ export function Timeline() { className="absolute top-0 w-0.5 bg-red-500 pointer-events-auto z-50 cursor-col" style={{ left: `${playheadPosition * TIMELINE_CONSTANTS.PIXELS_PER_SECOND * zoomLevel}px`, - height: `${tracks.length * TIMELINE_CONSTANTS.TRACK_HEIGHT}px`, + height: `${getTotalTracksHeight(tracks)}px`, }} onMouseDown={handlePlayheadMouseDown} /> -- cgit v1.3.1