Skip to content

🎥 Make videos programmatically with React

premount width

Jonny Burgere024181b36bf
diff --git a/packages/core/src/Sequence.tsx b/packages/core/src/Sequence.tsx
index 8d2ba79343..90bc3a3f3e 100644
--- a/packages/core/src/Sequence.tsx
+++ b/packages/core/src/Sequence.tsx
@@ -287,12 +287,12 @@ const PremountedSequenceRefForwardingFunction: React.ForwardRefRenderFunction<
}, [active, passedStyle]);
return (
- <Freeze frame={from - premountFor} active={active}>
+ <Freeze frame={from} active={active}>
<Sequence
ref={ref}
- from={from + (active ? -premountFor : 0)}
+ from={from}
style={style}
- premountDisplay={active ? premountFor : undefined}
+ premountDisplay={premountFor}
{...otherProps}
/>
</Freeze>
diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsx
index 2b29e51fad..15f0e2ab9c 100644
--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx
@@ -45,10 +45,15 @@ const Inner: React.FC<{
const frame = useCurrentFrame();
const relativeFrame = frame - s.from;
+ const relativeFrameWithPremount = relativeFrame + (s.premountDisplay ?? 0);
const roundedFrame = Math.round(relativeFrame * 100) / 100;
const isInRange = relativeFrame >= 0 && relativeFrame < s.duration;
+ const isPremounting =
+ relativeFrameWithPremount >= 0 &&
+ relativeFrameWithPremount < s.duration &&
+ !isInRange;
const {marginLeft, width, premountWidth} = useMemo(() => {
return getTimelineSequenceLayout({
@@ -95,8 +100,8 @@ const Inner: React.FC<{
-45deg,
transparent,
transparent 2px,
- rgba(255, 255, 255, 0.2) 2px,
- rgba(255, 255, 255, 0.2) 4px
+ rgba(255, 255, 255, ${isPremounting ? 0.5 : 0.2}) 2px,
+ rgba(255, 255, 255, ${isPremounting ? 0.5 : 0.2}) 4px
)`,
position: 'absolute',
}}
@@ -123,17 +128,17 @@ const Inner: React.FC<{
{s.type !== 'audio' &&
s.type !== 'video' &&
s.loopDisplay === undefined &&
- isInRange ? (
+ (isInRange || isPremounting) ? (
<div
style={{
- paddingLeft: 5,
+ paddingLeft: 5 + (premountWidth ?? 0),
height: '100%',
display: 'flex',
alignItems: 'center',
}}
>
<TimelineSequenceFrame
- premountDisplay={premountWidth}
+ premounted={isPremounting}
roundedFrame={roundedFrame}
/>
</div>
diff --git a/packages/studio/src/components/Timeline/TimelineSequenceFrame.tsx b/packages/studio/src/components/Timeline/TimelineSequenceFrame.tsx
index 9152f7b041..28425d02c5 100644
--- a/packages/studio/src/components/Timeline/TimelineSequenceFrame.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequenceFrame.tsx
@@ -9,11 +9,11 @@ const relativeFrameStyle: React.CSSProperties = {
export const TimelineSequenceFrame: React.FC<{
roundedFrame: number;
- premountDisplay: number | null;
-}> = ({roundedFrame, premountDisplay}) => {
+ premounted: boolean;
+}> = ({roundedFrame, premounted}) => {
return (
<div style={relativeFrameStyle}>
- {premountDisplay ? '0 (Premounted)' : roundedFrame}
+ {premounted ? '0 (Premounted)' : roundedFrame}
</div>
);
};
diff --git a/packages/studio/src/helpers/get-timeline-sequence-layout.ts b/packages/studio/src/helpers/get-timeline-sequence-layout.ts
index 365c343cf6..ad63ad2576 100644
--- a/packages/studio/src/helpers/get-timeline-sequence-layout.ts
+++ b/packages/studio/src/helpers/get-timeline-sequence-layout.ts
@@ -97,8 +97,8 @@ export const getTimelineSequenceLayout = ({
: null;
return {
- marginLeft: Math.round(Math.max(marginLeft, 0)),
- width,
+ marginLeft: Math.round(Math.max(marginLeft, 0)) - (premountWidth ?? 0),
+ width: width + (premountWidth ?? 0),
premountWidth,
};
};