interpolateStyles()
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.
Example
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 } />;
};API
A function that takes 3-4 arguments:
- The input value.
- The range of values that you expect the input to assume.
- The range of output styles that you want the input to map to.
- Options object, same as the options of
interpolate(). Optional.
Return value
- A style object representing the interpolated styles based on the current frame.
Usage Notes
-
Ensure that the
inputRangeandoutputStylesRangearrays contain at least two values to facilitate interpolation between styles. -
The
outputStylesRangearray must have the same number of elements asinputRange. Each style inoutputStylesRangecorresponds to a specific value in the input range.