useSpring
Creates a reactive Link whose value is interpolated according to a physically based spring.
Importing
1
import { useSpring } from '@infinityfx/lively/hooks';Usage
Call signature
1
const spring = useSpring<T extends number | number[]>(initial, { stiffness, damping, mass, restThreshold })Parameters
initial:
number | number[] The initial value/values of the spring.
stiffness?:
number = 2The stiffness of the spring.
damping?:
number = 0.1The damping of the spring between 0 and 1.
mass?:
number = 1The amount of mass attached to the spring.
restThreshold?:
number = 0.01The threshold for the velocity of the spring, below which the spring stops animating and is considered to be at rest.
Returns
link:
Link<number | number[]> A link which can be used inside the animate property to create an animation.