fix caption lane controls and preview behavior

This commit is contained in:
haixin.yang committed 2026-07-17 19:42:55 +08:00
1 parent eb3501b211
commit 2b9a1e7e0b
10 files changed
+146 -56

No files matched your search

+14
View File
@@ -12,6 +12,7 @@ import {
moveTimedCaptionSegment,
materializeCaptionTimings,
packTimedSegmentsIntoLanes,
packCaptionSegmentsIntoLanes,
reorderTimelineItems,
} from "./timeline.js";
import {
@@ -141,3 +142,16 @@ describe("timeline primitives", () => {
expect(sticker.duration).toBeGreaterThanOrEqual(0.5);
});
});
it("packs overlapping captions into separate stable lanes", () => {
const segments = [{ id: "a" }, { id: "b" }, { id: "c" }];
const timeline = [
{ start: 0, end: 4 },
{ start: 0, end: 2 },
{ start: 2, end: 4 },
];
const lanes = packCaptionSegmentsIntoLanes(segments, timeline);
expect(lanes).toHaveLength(2);
expect(lanes[0].map(({ segment }) => segment.id)).toEqual(["a"]);
expect(lanes[1].map(({ segment }) => segment.id)).toEqual(["b", "c"]);
});