feat: timeline zooms to clip region on cut-clip from Player mode
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -22,6 +22,14 @@
|
||||
|
||||
type ClipDragTarget = { clipId: string; edge: 'start' | 'end' };
|
||||
|
||||
let {
|
||||
zoomRegion,
|
||||
onZoomApplied,
|
||||
}: {
|
||||
zoomRegion?: { start: number; end: number } | null;
|
||||
onZoomApplied?: () => void;
|
||||
} = $props();
|
||||
|
||||
let canvas = $state<HTMLCanvasElement | null>(null);
|
||||
let minimapCanvas = $state<HTMLCanvasElement | null>(null);
|
||||
let containerEl = $state<HTMLDivElement | null>(null);
|
||||
@@ -189,6 +197,19 @@
|
||||
}
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (zoomRegion && session.duration > 0) {
|
||||
const clipLen = zoomRegion.end - zoomRegion.start;
|
||||
const pad = Math.max(clipLen * 0.2, 2);
|
||||
const vs = Math.max(0, zoomRegion.start - pad);
|
||||
const ve = Math.min(session.duration, zoomRegion.end + pad);
|
||||
timelineState.visibleStart = vs;
|
||||
timelineState.visibleEnd = ve;
|
||||
timelineState.zoom = session.duration / (ve - vs);
|
||||
onZoomApplied?.();
|
||||
}
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (!containerEl) return;
|
||||
const observer = new ResizeObserver((entries) => {
|
||||
|
||||
Reference in New Issue
Block a user