mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 23:03:09 +00:00
feat(studio): drag a clip past the video end to extend its duration
Dragging a timeline clip (or its right resize edge) past the end of the video now extends the composition duration on drop, instead of clamping the clip at the current end. Extend-only and undoable. - Relax the move/resize horizontal clamps that pinned a clip's end at the current duration; effectiveDuration now folds in the active drag/resize preview so the ruler and track width grow live as you drag past the end. - On drop, extend the root composition data-duration (and the store) when the clip's new end exceeds it, via a shared extendRootDurationInSource helper extracted from the block installer (now the single owner of that logic). An extending edit routes through the server persist path since the SDK setTiming op can't express the root composition's own duration.
This commit is contained in:
@@ -180,14 +180,6 @@ export const Timeline = memo(function Timeline({
|
||||
if (shortcutHintRafRef.current) cancelAnimationFrame(shortcutHintRafRef.current);
|
||||
});
|
||||
|
||||
const effectiveDuration = useMemo(() => {
|
||||
const safeDur = Number.isFinite(duration) ? duration : 0;
|
||||
if (rawElements.length === 0) return safeDur;
|
||||
const maxEnd = Math.max(...rawElements.map((el) => el.start + el.duration));
|
||||
const result = Math.max(safeDur, maxEnd);
|
||||
return Number.isFinite(result) ? result : safeDur;
|
||||
}, [rawElements, duration]);
|
||||
|
||||
const tracks = useMemo(
|
||||
() => buildStackingTimelineLayers(expandedElements).rows,
|
||||
[expandedElements],
|
||||
@@ -210,8 +202,7 @@ export const Timeline = memo(function Timeline({
|
||||
expandedElementsRef.current = expandedElements;
|
||||
|
||||
const ppsRef = useRef(100);
|
||||
const durationRef = useRef(effectiveDuration);
|
||||
durationRef.current = effectiveDuration;
|
||||
const durationRef = useRef(Number.isFinite(duration) ? duration : 0);
|
||||
|
||||
// Stable ref so useTimelineClipDrag can clear rangeSelection without circular dep
|
||||
const setRangeSelectionRef = useRef<((sel: null) => void) | null>(null);
|
||||
@@ -227,7 +218,6 @@ export const Timeline = memo(function Timeline({
|
||||
} = useTimelineClipDrag({
|
||||
scrollRef,
|
||||
ppsRef,
|
||||
durationRef,
|
||||
trackOrderRef,
|
||||
timelineLayersRef,
|
||||
timelineElementsRef: expandedElementsRef,
|
||||
@@ -238,6 +228,22 @@ export const Timeline = memo(function Timeline({
|
||||
setRangeSelectionRef,
|
||||
});
|
||||
|
||||
const effectiveDuration = useMemo(() => {
|
||||
const safeDur = Number.isFinite(duration) ? duration : 0;
|
||||
let maxEnd = safeDur;
|
||||
if (rawElements.length > 0) {
|
||||
maxEnd = Math.max(maxEnd, ...rawElements.map((el) => el.start + el.duration));
|
||||
}
|
||||
if (draggedClip?.started) {
|
||||
maxEnd = Math.max(maxEnd, draggedClip.previewStart + draggedClip.element.duration);
|
||||
}
|
||||
if (resizingClip?.started) {
|
||||
maxEnd = Math.max(maxEnd, resizingClip.previewStart + resizingClip.previewDuration);
|
||||
}
|
||||
return Number.isFinite(maxEnd) ? maxEnd : safeDur;
|
||||
}, [rawElements, duration, draggedClip, resizingClip]);
|
||||
durationRef.current = effectiveDuration;
|
||||
|
||||
const displayTrackOrder = useMemo(() => {
|
||||
if (
|
||||
!draggedClip?.started ||
|
||||
|
||||
Reference in New Issue
Block a user