Skip to content

🎥 Make videos programmatically with React

@remotion/studio: Fix timeline trim handles with premounting

Jonny Burger4279daedf073
diff --git a/packages/studio/src/components/Timeline/TimelineLayerEye.tsx b/packages/studio/src/components/Timeline/TimelineLayerEye.tsx
index 3b7eef47db..237a680c67 100644
--- a/packages/studio/src/components/Timeline/TimelineLayerEye.tsx
+++ b/packages/studio/src/components/Timeline/TimelineLayerEye.tsx
@@ -155,12 +155,10 @@ export const TimelineLayerEye: React.FC<{
[onInvoked],
);
- const onDoubleClick: React.MouseEventHandler<HTMLDivElement> = useCallback(
- (e) => {
+ const stopClickPropagation: React.MouseEventHandler<HTMLDivElement> =
+ useCallback((e) => {
e.stopPropagation();
- },
- [],
- );
+ }, []);
return (
<div
@@ -169,7 +167,8 @@ export const TimelineLayerEye: React.FC<{
style={timelineLayerIconContainer}
draggable={false}
onDragStart={onDragStart}
- onDoubleClick={onDoubleClick}
+ onClick={stopClickPropagation}
+ onDoubleClick={stopClickPropagation}
onPointerEnter={onInvoked === null ? undefined : onPointerEnter}
onPointerDown={onPointerDown}
>
diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsx
index 84d7cd5298..b3ce62d214 100644
--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx
@@ -1421,7 +1421,7 @@ const TimelineSequenceInner: React.FC<{
validatedLocation !== null &&
trimBeforeCanUpdate &&
(isMedia || durationCanUpdate) &&
- (visibleLayout?.width ?? 0) >= MIN_SECONDARY_LEFT_EDGE_ACTION_WIDTH;
+ (visibleLayout?.media?.width ?? 0) >= MIN_SECONDARY_LEFT_EDGE_ACTION_WIDTH;
const secondaryLeftEdgeAction = canShowSecondaryLeftEdgeAction
? isMedia
? 'source-only'
@@ -1462,25 +1462,36 @@ const TimelineSequenceInner: React.FC<{
edgeDragHandles={
<>
{(showLeftEdgeDragHandle || secondaryLeftEdgeAction) &&
- visibleLayout.leftEdgeVisible &&
+ visibleLayout.media?.offset === 0 &&
negativeStartWidth === 0 &&
nodePathInfo &&
validatedLocation ? (
- <TimelineSequenceLeftEdgeDragHandle
- cursor={`${timelineTrimEdgeCursor}, ew-resize`}
- trimBeforeCursor={`${timelineLeftEdgeCursor}, e-resize`}
- edgeEnabled={showLeftEdgeDragHandle}
- secondaryAction={secondaryLeftEdgeAction}
- nodePathInfo={nodePathInfo}
- windowWidth={windowWidth}
- timelineDurationInFrames={video.durationInFrames ?? 1}
- initialEdgeFrame={s.from}
- fps={video.fps}
- onDragStart={startLeftEdgeDrag}
- onDragEnd={endEdgeDrag}
- onSelect={onSelect}
- selected={selected}
- />
+ <div
+ style={{
+ position: 'absolute',
+ left: visibleLayout.media.left,
+ width: visibleLayout.media.width,
+ top: 0,
+ bottom: 0,
+ pointerEvents: 'none',
+ }}
+ >
+ <TimelineSequenceLeftEdgeDragHandle
+ cursor={`${timelineTrimEdgeCursor}, ew-resize`}
+ trimBeforeCursor={`${timelineLeftEdgeCursor}, e-resize`}
+ edgeEnabled={showLeftEdgeDragHandle}
+ secondaryAction={secondaryLeftEdgeAction}
+ nodePathInfo={nodePathInfo}
+ windowWidth={windowWidth}
+ timelineDurationInFrames={video.durationInFrames ?? 1}
+ initialEdgeFrame={s.from}
+ fps={video.fps}
+ onDragStart={startLeftEdgeDrag}
+ onDragEnd={endEdgeDrag}
+ onSelect={onSelect}
+ selected={selected}
+ />
+ </div>
) : null}
{showRightEdgeDragHandle &&
visibleLayout.rightEdgeVisible &&
diff --git a/packages/studio/src/components/Timeline/TimelineSequenceRightEdgeDragHandle.tsx b/packages/studio/src/components/Timeline/TimelineSequenceRightEdgeDragHandle.tsx
index e92cfa9977..1e451fa78b 100644
--- a/packages/studio/src/components/Timeline/TimelineSequenceRightEdgeDragHandle.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequenceRightEdgeDragHandle.tsx
@@ -1925,6 +1925,7 @@ const TimelineSequenceLeftEdgeDragHandleInner: React.FC<{
width: `calc(${LEFT_EDGE_HANDLE_OUTSET}px + min(${LEFT_EDGE_HANDLE_INSET}px, 12.5%))`,
cursor,
background: TRANSPARENT,
+ pointerEvents: 'auto',
};
const trimBeforeStyle: React.CSSProperties = {
...baseStyle,
@@ -1932,6 +1933,7 @@ const TimelineSequenceLeftEdgeDragHandleInner: React.FC<{
width: edgeEnabled ? 'min(10px, 12.5%)' : 'min(14px, 25%)',
cursor: trimBeforeCursor,
background: TRANSPARENT,
+ pointerEvents: 'auto',
};
return (
@@ -1943,6 +1945,7 @@ const TimelineSequenceLeftEdgeDragHandleInner: React.FC<{
aria-label="Drag to trim start"
style={edgeStyle}
onPointerDown={onPointerDown}
+ onClick={(e) => e.stopPropagation()}
/>
) : null}
{secondaryAction ? (
@@ -1957,6 +1960,7 @@ const TimelineSequenceLeftEdgeDragHandleInner: React.FC<{
data-trim-mode={secondaryAction}
style={trimBeforeStyle}
onPointerDown={onPointerDown}
+ onClick={(e) => e.stopPropagation()}
/>
) : null}
{trimTooltip === null ? null : (
@@ -2696,6 +2700,7 @@ const TimelineSequenceRightEdgeDragHandleInner: React.FC<{
aria-label="Drag to change duration"
style={style}
onPointerDown={onPointerDown}
+ onClick={(e) => e.stopPropagation()}
/>
{trimTooltip === null ? null : (
<TimelineTrimTooltip state={trimTooltip} fps={fps} />