packages/docs/docs/animation-utils/interpolate-styles.mdx
Part of the @remotion/animation-utils package.
This function provides a convenient way to interpolate styles based on a specified range of values, allowing for smooth animations between different styles.
// ---cut---
import {
interpolateStyles,
makeTransform,
translateY,
} from "@remotion/animation-utils";
const MyComponent: React.FC = () => {
const animatedStyles = interpolateStyles(
15,
[0, 30, 60],
[
{ opacity: 0, transform: makeTransform([translateY(-50)]) },
{ opacity: 1, transform: makeTransform([translateY(0)]) },
{ opacity: 0, transform: makeTransform([translateY(50)]) },
],
);
return <div style={animatedStyles} />;
};
A function that takes 3-4 arguments:
interpolate() (extrapolateLeft, extrapolateRight, easing), including a per-segment easing array when you have more than two keyframes. Optional.Ensure that the inputRange and outputStylesRange arrays contain at least two values to facilitate interpolation between styles.
The outputStylesRange array must have the same number of elements as inputRange. Each style in outputStylesRange corresponds to a specific value in the input range.