To make animations editable in the Studio, write interpolate() calls directly inside the style object.
Requirements for Interactivity:
- Inline Calls: The
interpolate() call must be inside the markup, not assigned to a variable beforehand. - Hardcoded Values: The output range, easing, extrapolation, and
output property must use hardcoded values. - Supported Variables: You can use
frame and values destructured from useVideoConfig() (like fps, durationInFrames, width, and height). - Supported Math: You can use bare identifiers, multiplication with numbers (e.g.,
2 * fps), or subtraction (e.g., durationInFrames - 1). - CSS Properties: Use
scale, rotate, and translate instead of the transform property, as only the individual properties are interactively editable.
const {fps, durationInFrames} = useVideoConfig();
<Interactive.Div
name="Product card"
style={{
color: 'white',
fontSize: 80,
scale: interpolate(frame, [0, fps], [0, 1], {
easing: Easing.spring({damping: 200}),
output: 'perceptual-scale',
extrapolateLeft: 'clamp',
extrapolateRight: 'clamp'
}),
rotate: interpolate(frame, [0, 1 * fps], ['0deg', '20deg'], {
easing: Easing.spring({damping: 200}),
extrapolateLeft: 'clamp',
extrapolateRight: 'clamp'
}),
translate: interpolate(frame, [durationInFrames - 30, durationInFrames], ['0px 0px', '0px 120px'], {
easing: Easing.spring({damping: 200}),
output: 'perceptual-scale',
extrapolateLeft: 'clamp',
extrapolateRight: 'clamp'
}),
}}
/>