summaryrefslogtreecommitdiff
path: root/apps/web/src/types
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2025-07-22 01:01:54 +0200
committerMaze Winther <mazewinther@gmail.com>2025-07-22 01:01:54 +0200
commitc783062121a4a31ec6ee20c4ca52fd47f4fbdab7 (patch)
treef7d2a8845b6139ef4e75e1a9ab6a6a29e1a3a8f3 /apps/web/src/types
parent550f5363fde76b9cbe2d6f06f55ff27be44223ee (diff)
downloadopencut-c783062121a4a31ec6ee20c4ca52fd47f4fbdab7.tar.gz
feat: ensure text tracks are always created above media tracks
Diffstat (limited to 'apps/web/src/types')
-rw-r--r--apps/web/src/types/timeline.ts12
1 files changed, 9 insertions, 3 deletions
diff --git a/apps/web/src/types/timeline.ts b/apps/web/src/types/timeline.ts
index 17dbb5d1..f8a79d03 100644
--- a/apps/web/src/types/timeline.ts
+++ b/apps/web/src/types/timeline.ts
@@ -89,13 +89,19 @@ export interface TimelineTrack {
export function sortTracksByOrder(tracks: TimelineTrack[]): TimelineTrack[] {
return [...tracks].sort((a, b) => {
+ // Text tracks always go to the top
+ if (a.type === "text" && b.type !== "text") return -1;
+ if (b.type === "text" && a.type !== "text") return 1;
+
// Audio tracks always go to bottom
if (a.type === "audio" && b.type !== "audio") return 1;
if (b.type === "audio" && a.type !== "audio") return -1;
- // Main track goes above audio but below other tracks
- if (a.isMain && !b.isMain && b.type !== "audio") return 1;
- if (b.isMain && !a.isMain && a.type !== "audio") return -1;
+ // Main track goes above audio but below text tracks
+ if (a.isMain && !b.isMain && b.type !== "audio" && b.type !== "text")
+ return 1;
+ if (b.isMain && !a.isMain && a.type !== "audio" && a.type !== "text")
+ return -1;
// Within same category, maintain creation order
return 0;