🎥 Make videos programmatically with React
feat: show postmount in studio timeline
Shankhadeep Dey322f7c3c49da
diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsxindex a8fe309450..13f3386357 100644--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx@@ -48,6 +48,7 @@ const Inner: React.FC<{const frame = useCurrentFrame();const relativeFrame = frame - s.from;const relativeFrameWithPremount = relativeFrame + (s.premountDisplay ?? 0);+ const relativeFrameWithPostmount = relativeFrame - s.duration;const roundedFrame = Math.round(relativeFrame * 100) / 100;@@ -56,8 +57,12 @@ const Inner: React.FC<{relativeFrameWithPremount >= 0 &&relativeFrameWithPremount < s.duration &&!isInRange;+ const isPostmounting =+ relativeFrameWithPostmount >= 0 &&+ relativeFrameWithPostmount < (s.postmountDisplay ?? 0) &&+ !isInRange;- const {marginLeft, width, premountWidth} = useMemo(() => {+ const {marginLeft, width, premountWidth, postmountWidth} = useMemo(() => {return getTimelineSequenceLayout({durationInFrames: s.loopDisplay? s.loopDisplay.durationInFrames * s.loopDisplay.numberOfTimes@@ -68,6 +73,7 @@ const Inner: React.FC<{video,windowWidth,premountDisplay: s.premountDisplay,+ postmountDisplay: s.postmountDisplay,});}, [maxMediaDuration, s, video, windowWidth]);@@ -114,6 +120,24 @@ const Inner: React.FC<{/>) : null}+ {postmountWidth ? (+ <div+ style={{+ width: postmountWidth,+ height: '100%',+ background: `repeating-linear-gradient(+ -45deg,+ transparent,+ transparent 2px,+ rgba(255, 255, 255, ${isPostmounting ? 0.5 : 0.2}) 2px,+ rgba(255, 255, 255, ${isPostmounting ? 0.5 : 0.2}) 4px+ )`,+ position: 'absolute',+ right: 0,+ }}+ />+ ) : null}+{s.type === 'audio' ? (<AudioWaveformsrc={s.src}@@ -140,7 +164,7 @@ const Inner: React.FC<{{s.type !== 'audio' &&s.type !== 'video' &&s.loopDisplay === undefined &&- (isInRange || isPremounting) ? (+ (isInRange || isPremounting || isPostmounting) ? (<divstyle={{paddingLeft: 5 + (premountWidth ?? 0),@@ -151,6 +175,7 @@ const Inner: React.FC<{><TimelineSequenceFramepremounted={isPremounting}+ postmounted={isPostmounting}roundedFrame={roundedFrame}/></div>diff --git a/packages/studio/src/components/Timeline/TimelineSequenceFrame.tsx b/packages/studio/src/components/Timeline/TimelineSequenceFrame.tsxindex d72d5ce551..1648f48deb 100644--- a/packages/studio/src/components/Timeline/TimelineSequenceFrame.tsx+++ b/packages/studio/src/components/Timeline/TimelineSequenceFrame.tsx@@ -10,10 +10,15 @@ const relativeFrameStyle: React.CSSProperties = {export const TimelineSequenceFrame: React.FC<{readonly roundedFrame: number;readonly premounted: boolean;-}> = ({roundedFrame, premounted}) => {+ readonly postmounted: boolean;+}> = ({roundedFrame, premounted, postmounted}) => {return (<div style={relativeFrameStyle}>- {premounted ? '0 (Premounted)' : roundedFrame}+ {premounted+ ? '0 (Premounted)'+ : postmounted+ ? 'Last (Postmounted)'+ : roundedFrame}</div>);};diff --git a/packages/studio/src/helpers/calculate-timeline.ts b/packages/studio/src/helpers/calculate-timeline.tsindex fd171417e8..6c83a9485c 100644--- a/packages/studio/src/helpers/calculate-timeline.ts+++ b/packages/studio/src/helpers/calculate-timeline.ts@@ -37,6 +37,7 @@ export const calculateTimeline = ({loopDisplay: undefined,stack: null,premountDisplay: null,+ postmountDisplay: null,},depth: 0,hash: '-',diff --git a/packages/studio/src/helpers/get-timeline-sequence-layout.ts b/packages/studio/src/helpers/get-timeline-sequence-layout.tsindex 4723d9ce59..74d6c9c5b2 100644--- a/packages/studio/src/helpers/get-timeline-sequence-layout.ts+++ b/packages/studio/src/helpers/get-timeline-sequence-layout.ts@@ -33,6 +33,7 @@ export const getTimelineSequenceLayout = ({video,windowWidth,premountDisplay,+ postmountDisplay,}: {durationInFrames: number;startFrom: number;@@ -41,6 +42,7 @@ export const getTimelineSequenceLayout = ({video: VideoConfig;windowWidth: number;premountDisplay: number | null;+ postmountDisplay: number | null;}) => {const maxMediaSequenceDuration =(maxMediaDuration ?? Infinity) - startFromMedia;@@ -92,9 +94,20 @@ export const getTimelineSequenceLayout = ({}): null;+ const postmountWidth = postmountDisplay+ ? getWidthOfTrack({+ durationInFrames: postmountDisplay,+ lastFrame,+ nonNegativeMarginLeft,+ spatialDuration: postmountDisplay,+ windowWidth,+ })+ : null;+return {marginLeft: Math.max(marginLeft, 0) - (premountWidth ?? 0),- width: width + (premountWidth ?? 0),+ width: width + (premountWidth ?? 0) + (postmountWidth ?? 0),premountWidth,+ postmountWidth,};};