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
= 2
The stiffness of the spring.
damping?:
number
= 0.1
The damping of the spring between 0 and 1.
mass?:
number
= 1
The amount of mass attached to the spring.
restThreshold?:
number
= 0.01
The 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.