🎥 Make videos programmatically with React
Docs: Introduce from before duration
JonnyBurgera1199ae36b88
diff --git a/packages/docs/components/TimingTimeline.tsx b/packages/docs/components/TimingTimeline.tsxindex a0321b62bd..058928c7dc 100644--- a/packages/docs/components/TimingTimeline.tsx+++ b/packages/docs/components/TimingTimeline.tsx@@ -2,7 +2,7 @@ import React, {useRef, useState} from 'react';export const TimingTimeline: React.FC<{readonly from: number;- readonly durationInFrames: number;+ readonly durationInFrames?: number;readonly trimBefore: number;readonly playbackRate: number;}> = ({from, durationInFrames, trimBefore, playbackRate}) => {@@ -10,8 +10,9 @@ export const TimingTimeline: React.FC<{const scrubbingPointer = useRef<number | null>(null);const totalFrames = 90;const fps = 30;+ const displayedDuration = durationInFrames ?? totalFrames - from;const localFrame =- frame >= from && frame < from + durationInFrames+ frame >= from && frame < from + displayedDuration? (frame - from) * playbackRate + trimBefore: null;const seconds = Math.floor(frame / fps);@@ -168,7 +169,7 @@ export const TimingTimeline: React.FC<{style={{position: 'absolute',left: `${(from / totalFrames) * 100}%`,- width: `${(durationInFrames / totalFrames) * 100}%`,+ width: `${(displayedDuration / totalFrames) * 100}%`,height: 21,boxSizing: 'border-box',border: '1px solid rgba(255, 255, 255, 0.2)',diff --git a/packages/docs/docs/timing.mdx b/packages/docs/docs/timing.mdxindex f2b0e3dc46..9477583e3c 100644--- a/packages/docs/docs/timing.mdx+++ b/packages/docs/docs/timing.mdx@@ -22,7 +22,7 @@ The listed components also accept `playbackRate`, except [`<Img>`](/docs/img) an`from` moves an item on its parent timeline. By default, its children start at frame `0` when it appears:-<TimingTimeline from={30} durationInFrames={30} trimBefore={0} playbackRate={1} />+<TimingTimeline from={30} trimBefore={0} playbackRate={1} />```tsx twoslash title="MyComposition.tsx"import {Interactive, useCurrentFrame} from 'remotion';@@ -30,13 +30,13 @@ import {Interactive, useCurrentFrame} from 'remotion';const Counter = () => <div>{useCurrentFrame()}</div>;export const MyComposition = () => (- <Interactive.Div from={30} durationInFrames={30}>+ <Interactive.Div from={30}><Counter /></Interactive.Div>);```-Drag the playhead across the element. The counter on the left shows composition frames `30` through `59`. The label inside the element shows its local frame, `0` through `29`, matching `<Counter>`.+Drag the playhead across the element. At composition frame `30`, the counter on the left shows `30`, while the label inside the element and `<Counter>` show `0`. At composition frame `40`, the left counter shows `40` and the local frame is `10`.## `durationInFrames`: Limit an item