Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply best practices for creating programmatic videos with Remotion and React
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/timing.md
1---2name: timing3description: Interpolation and timing in Remotion—prefer interpolate with Bézier easing; springs as a specialized option4metadata:5tags: easing, bezier, interpolation, spring, timing6---78Drive motion with `interpolate()` over explicit frame range. To customize timing, use **`Easing.bezier`**. The four parameters are the same as CSS `cubic-bezier(x1, y1, x2, y2)`.910A simple linear interpolation is done using the `interpolate` function.1112```ts title="Going from 0 to 1 over 100 frames"13import { interpolate } from "remotion";1415const opacity = interpolate(frame, [0, 100], [0, 1]);16```1718By default, the values are not clamped, so the value can go outside the range [0, 1].19Here is how they can be clamped:2021```ts title="Going from 0 to 1 over 100 frames with extrapolation"22const opacity = interpolate(frame, [0, 100], [0, 1], {23extrapolateRight: "clamp",24extrapolateLeft: "clamp",25});26```2728## Bézier easing2930Use `Easing.bezier(x1, y1, x2, y2)` inside the `interpolate` options object. The curve is identical in spirit to CSS animations and transitions, which helps when you are stealing timing from the web or from a designer’s spec.3132```ts33import { interpolate, Easing } from "remotion";3435const opacity = interpolate(frame, [0, 60], [0, 1], {36easing: Easing.bezier(0.16, 1, 0.3, 1),37extrapolateLeft: "clamp",38extrapolateRight: "clamp",39});40```4142### Examples (copy-paste curves)4344**1. Crisp UI entrance (strong ease-out, no overshoot)** — slows nicely into the rest value; similar to many system “deceleration” curves.4546```tsx47const enter = interpolate(frame, [0, 45], [0, 1], {48easing: Easing.bezier(0.16, 1, 0.3, 1),49extrapolateLeft: "clamp",50extrapolateRight: "clamp",51});52```5354**2. Editorial / slow fade (balanced ease-in-out)** — symmetric acceleration and deceleration over a hold-friendly move.5556```tsx57const progress = interpolate(frame, [0, 90], [0, 1], {58easing: Easing.bezier(0.45, 0, 0.55, 1),59extrapolateLeft: "clamp",60extrapolateRight: "clamp",61});62```6364**3. Playful overshoot (control point y > 1)** — a little past the target then settles; use sparingly for emphasis.6566```tsx67const pop = interpolate(frame, [0, 30], [0, 1], {68easing: Easing.bezier(0.34, 1.56, 0.64, 1),69extrapolateLeft: "clamp",70extrapolateRight: "clamp",71});72```7374## Preset easings (`Easing.in` / `Easing.out` / named curves)7576Easing can be added to the `interpolate` function without a custom cubic:7778```ts79import { interpolate, Easing } from "remotion";8081const value1 = interpolate(frame, [0, 100], [0, 1], {82easing: Easing.inOut(Easing.cubic),83extrapolateLeft: "clamp",84extrapolateRight: "clamp",85});86```8788The default easing is `Easing.linear`.89Convexities:9091- `Easing.in` — starting slow and accelerating92- `Easing.out` — starting fast and slowing down93- `Easing.inOut`9495Named curves (from most linear to most curved):9697- `Easing.quad`98- `Easing.cubic` (good default when you do not need a custom cubic)99- `Easing.sin`100- `Easing.exp`101- `Easing.circle`102103### Easing direction for enter/exit animations104105Use `Easing.out` for enter animations (starts fast, decelerates into place) and `Easing.in` for exit animations (starts slow, accelerates away). This feels natural because elements arrive with momentum and leave with gravity. When you need a specific curve from design, prefer a single `Easing.bezier(...)` instead of stacking presets.106107## Composing interpolations108109When multiple properties share the same timing (e.g. a slide-in panel and a video shift), avoid duplicating the full interpolation for each property. Instead, create a single normalized progress value (0 to 1) and derive each property from it:110111```tsx112const slideIn = interpolate(113frame,114[slideInStart, slideInStart + slideInDuration],115[0, 1],116{117easing: Easing.bezier(0.22, 1, 0.36, 1),118extrapolateLeft: "clamp",119extrapolateRight: "clamp",120},121);122const slideOut = interpolate(123frame,124[slideOutStart, slideOutStart + slideOutDuration],125[0, 1],126{ easing: Easing.in(Easing.cubic), extrapolateLeft: "clamp", extrapolateRight: "clamp" },127);128const progress = slideIn - slideOut;129130// Derive multiple properties from the same progress131const overlayX = interpolate(progress, [0, 1], [100, 0]);132const videoX = interpolate(progress, [0, 1], [0, -20]);133const opacity = interpolate(progress, [0, 1], [0, 1]);134```135136The key idea: separate **timing** (when and how fast) from **mapping** (what values to animate between).137