packages/skills/skills/remotion-markup/timing.md
Drive motion with interpolate() over an explicit frame range.
To customize timing, use Easing.bezier or Easing.spring.
A simple linear interpolation is done using the interpolate function.
import { interpolate } from "remotion";
const opacity = interpolate(frame, [0, 0.3 * fps], [0, 1]);
By default, the values are not clamped, so the value can go outside the range [0, 1].
Here is how they can be clamped:
const opacity = interpolate(frame, [0, 0.3 * fps], [0, 1], {
extrapolateRight: "clamp",
extrapolateLeft: "clamp",
});
When an animation should be editable in Remotion Studio, keep the interpolate() call directly in the style prop and prefer individual CSS transform properties:
// 👍 Inline editable keyframes and transform shorthands
style={{
scale: interpolate(frame, [0, 100], [0, 1]),
translate: interpolate(frame, [0, 100], ["0px 0px", "100px 100px"]),
rotate: interpolate(frame, [0, 100], ["20deg", "90deg"]),
}}
// 👎 Hidden values and transform strings become computed in Studio
const translateY = interpolate(frame, [0, 100], [0, 120]);
const rotation = interpolate(frame, [0, 100], [0, 20]);
style={{
transform: `translateY(${translateY}px) rotate(${rotation}deg)`,
}}
Use transform strings only when individual CSS transform properties do not cover the effect, such as skew(), perspective(), or order-sensitive multi-transform chains.
A nice push movement with no bounce:
import { interpolate, Easing } from "remotion";
const opacity = interpolate(frame, [0, 0.3 * fps], [0, 1], {
easing: Easing.spring({damping: 200}),
extrapolateLeft: "clamp",
extrapolateRight: "clamp",
});
Pass values like you would to a CSS cubic-bezier function.
import { interpolate, Easing } from "remotion";
const opacity = interpolate(frame, [0, 0.3 * fps], [0, 1], {
easing: Easing.bezier(0.16, 1, 0.3, 1),
extrapolateLeft: "clamp",
extrapolateRight: "clamp",
});
When animating scale, if the output is linear, the perceived scale would be smaller the larger the scale gets.
Use this option to compensate:
const scale = interpolate(frame, [0, 0.3 * fps], [0, 1], {
easing: Easing.bezier(0.16, 1, 0.3, 1),
extrapolateLeft: "clamp",
extrapolateRight: "clamp",
output: 'perceptual-scale' // <- Add this to scale animations
});
Add as many keyframes as you want. For multiple easings, pass an array with n - 1 items:
const scale = interpolate(frame, [0, 1 * fps, 9 * fps, 10 * fps], [0, 1, 1, 0], {
easing: [Easing.bezier(0.16, 1, 0.3, 1), Easing.linear, Easing.spring({damping: 200})],
extrapolateLeft: "clamp",
extrapolateRight: "clamp",
output: 'perceptual-scale' // <- Add this to scale animations
});
You can intentionally reduce the frame rate for artistic reason. Use if it makes sense.
const scale = interpolate(frame, [0, 1 * fps], [0, 1], {
easing: Easing.bezier(0.16, 1, 0.3, 1),
extrapolateLeft: "clamp",
extrapolateRight: "clamp",
posterize: 3 // Only every 3rd frame is sampled
});