Skip to content

🎥 Make videos programmatically with React

Place outgoing trim handles at the transition start

JonnyBurger3b6cfa4a4a91
diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsx
index d7332c3807..de2dd137fb 100644
--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx
@@ -2108,6 +2108,19 @@ const TimelineSequenceLayoutInner: React.FC<{
const parentEnd = parentVisibleEnd ?? video.durationInFrames;
const frameIncrement =
(windowWidth - TIMELINE_PADDING * 2) / video.durationInFrames;
+ const outgoingTransitionStart = isTransitionSeriesSequence(s)
+ ? (sceneRange?.transitionOutStart ?? null)
+ : null;
+ const transitionStartOffset =
+ outgoingTransitionStart !== null && visibleLayout !== null
+ ? Math.round(outgoingTransitionStart * frameIncrement) -
+ visibleLayout.marginLeft
+ : null;
+ const rightTrimHandleVisible =
+ transitionStartOffset !== null
+ ? transitionStartOffset >= 0 &&
+ transitionStartOffset <= (visibleLayout?.width ?? 0)
+ : visibleLayout?.rightEdgeVisible;
const layerHeight = getTimelineSequenceHeight(s);
const trimOutline = (() => {
if (
@@ -2495,11 +2508,12 @@ const TimelineSequenceLayoutInner: React.FC<{
) : null}
{s.timelineTrack?.role !== 'transition' &&
showRightEdgeDragHandle &&
- visibleLayout.rightEdgeVisible &&
+ rightTrimHandleVisible &&
nodePathInfo &&
validatedLocation ? (
<TimelineSequenceRightEdgeDragHandle
isTransitionSeries={isTransitionSeriesSequence(s)}
+ transitionStartOffset={transitionStartOffset}
touchingNext={nextTouchingSequence !== null}
onHoverEnd={clearEdgeHighlight}
cursor={`${isCascadingSequence(s) && !isTransitionSeriesSequence(s) ? timelineTrimEdgeCursor : timelineRightEdgeCursor}, ew-resize`}
@@ -2508,15 +2522,16 @@ const TimelineSequenceLayoutInner: React.FC<{
windowWidth={windowWidth}
timelineDurationInFrames={video.durationInFrames ?? 1}
initialEdgeFrame={
+ outgoingTransitionStart ??
s.from +
- Math.max(
- 0,
- Math.min(
- displayDurationInFrames,
- effectiveMaxMediaDuration ?? Infinity,
- video.durationInFrames - s.from,
- ),
- )
+ Math.max(
+ 0,
+ Math.min(
+ displayDurationInFrames,
+ effectiveMaxMediaDuration ?? Infinity,
+ video.durationInFrames - s.from,
+ ),
+ )
}
fps={video.fps}
onDragStart={startRightEdgeDrag}
diff --git a/packages/studio/src/components/Timeline/TimelineSequenceRightEdgeDragHandle.tsx b/packages/studio/src/components/Timeline/TimelineSequenceRightEdgeDragHandle.tsx
index 9f167348c5..79b9cde4c4 100644
--- a/packages/studio/src/components/Timeline/TimelineSequenceRightEdgeDragHandle.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequenceRightEdgeDragHandle.tsx
@@ -3189,6 +3189,7 @@ export const useTimelineSequenceFromDrag = ({
const TimelineSequenceRightEdgeDragHandleInner: React.FC<{
readonly cursor: string;
readonly isTransitionSeries: boolean;
+ readonly transitionStartOffset: number | null;
readonly touchingNext: boolean;
readonly onHoverEnd: () => void;
readonly nodePathInfo: SequenceNodePathInfo;
@@ -3208,6 +3209,7 @@ const TimelineSequenceRightEdgeDragHandleInner: React.FC<{
}> = ({
cursor,
isTransitionSeries,
+ transitionStartOffset,
touchingNext,
onHoverEnd,
nodePathInfo,
@@ -3395,8 +3397,10 @@ const TimelineSequenceRightEdgeDragHandleInner: React.FC<{
const propStatuses = propStatusesRef.current;
const handleRect = captureTarget.getBoundingClientRect();
const initialEdgeClientX =
- captureTarget.parentElement?.getBoundingClientRect().right ??
- handleRect.right - HANDLE_OUTSET;
+ transitionStartOffset !== null
+ ? handleRect.left + HANDLE_INSET
+ : (captureTarget.parentElement?.getBoundingClientRect().right ??
+ handleRect.right - HANDLE_OUTSET);
const initialEdgeClientY = handleRect.top;
const initialTimelineEdge = latestRef.current.initialEdgeFrame;
@@ -3630,6 +3634,7 @@ const TimelineSequenceRightEdgeDragHandleInner: React.FC<{
sequencesRef,
timelineDurationInFrames,
windowWidth,
+ transitionStartOffset,
updateSnapFrameRef,
],
);
@@ -3643,9 +3648,30 @@ const TimelineSequenceRightEdgeDragHandleInner: React.FC<{
const style: React.CSSProperties = {
...baseStyle,
- zIndex: isTransitionSeries ? 2 : baseStyle.zIndex,
- right: touchingNext ? 'min(2px, 12.5%)' : -HANDLE_OUTSET,
- width: touchingNext ? 'min(10px, 12.5%)' : baseStyle.width,
+ // The outgoing edge is above the seam; incoming controls remain below it.
+ zIndex:
+ transitionStartOffset !== null
+ ? 3
+ : isTransitionSeries
+ ? 2
+ : baseStyle.zIndex,
+ left:
+ transitionStartOffset !== null
+ ? transitionStartOffset - HANDLE_INSET
+ : undefined,
+ right:
+ transitionStartOffset !== null
+ ? undefined
+ : touchingNext
+ ? 'min(2px, 12.5%)'
+ : -HANDLE_OUTSET,
+ bottom: transitionStartOffset !== null ? '50%' : baseStyle.bottom,
+ width:
+ transitionStartOffset !== null
+ ? baseStyle.width
+ : touchingNext
+ ? 'min(10px, 12.5%)'
+ : baseStyle.width,
cursor,
background: TRANSPARENT,
};