interpolate function.
Going from 0 to 1 over 100 frames
Here is how they can be clamped:
Going from 0 to 1 over 100 frames with extrapolation
Spring animations
Spring animations have a more natural motion.They go from 0 to 1 over time.
Spring animation from 0 to 1 over 100 frames
Physical properties
The default configuration is:mass: 1, damping: 10, stiffness: 100.This leads to the animation having a bit of bounce before it settles. The config can be overwritten like this:
{ damping: 200 }.
Here are some common configurations:
Delay
The animation starts immediately by default.Use the
delay parameter to delay the animation by a number of frames.
Duration
Aspring() has a natural duration based on the physical properties.To stretch the animation to a specific duration, use the
durationInFrames parameter.
Combining spring() with interpolate()
Map spring output (0-1) to custom ranges:Adding springs
Springs return just numbers, so math can be performed:Easing
Easing can be added to theinterpolate function:
Easing.linear.There are various other convexities:
Easing.infor starting slow and acceleratingEasing.outfor starting fast and slowing downEasing.inOut
Easing.quadEasing.sinEasing.expEasing.circle