toCssLinear
Samples an easing function into a CSS linear() easing, so any curve (a spring, a
custom bounce) can be played by CSS transitions and the Web Animations API, which do not take
JavaScript functions.
Values are rounded to 4 decimals. More samples follow the curve more closely, in a longer string; 32 is smooth for most springs.
Available since v3.1.5
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
easing | function | The easing function over `[0, 1]` |
samples | number | Number of points, evenly spaced in time, at least `2`. Defaults to `32`. |
Returns
Section titled “Returns”string — A linear(...) string
Examples
Section titled “Examples”Play a spring with the Web Animations API
Section titled “Play a spring with the Web Animations API”Pass the spring duration and its sampled curve.
Any custom curve
Section titled “Any custom curve”Fewer samples give a shorter string.
