react-spring stiff
Its settle time is about the same as default (0.715 s against 0.705 s), but default does not overshoot. Stiffness 210, damping 20 and mass 1 give a damping ratio of 0.69, so the spring is underdamped. It settles to within 0.1% in 0.715 s. It passes the end value by up to 5% at 0.3 s and crosses it 2 times.
Demo
Both boxes take 0.715 s. Playing at 0.5× speed.
Your system asks for reduced motion, so nothing plays. The chart shows the whole move.
Code
A spring has no fixed duration, so the CSS takes the settle time (715 ms) and a linear() string that follows the spring.
transition: translate 715ms linear(0, 0.0079, 0.0297, 0.0629, 0.1049, 0.1539, 0.2078, 0.265, 0.3241, 0.384, 0.4434, 0.5017, 0.5581, 0.612, 0.6631, 0.711, 0.7554, 0.7964, 0.8337, 0.8675, 0.8978, 0.9247, 0.9484, 0.969, 0.9866, 1.0016, 1.0142, 1.0244, 1.0326, 1.039, 1.0437, 1.0469, 1.049, 1.0499, 1.0499, 1.0492, 1.0478, 1.0459, 1.0436, 1.041, 1.0383, 1.0353, 1.0324, 1.0294, 1.0264, 1.0235, 1.0208, 1.0181, 1.0157, 1.0134, 1.0112, 1.0093, 1.0075, 1.0059, 1.0044, 1.0032, 1.0021, 1.0011, 1.0003, 0.9996, 0.999, 0.9986, 0.9982, 0.9979, 0.9977, 0.9976, 0.9975, 0.9975, 0.9975, 0.9976, 0.9977, 0.9978, 0.9979, 0.998, 0.9982, 0.9983, 0.9985, 0.9986, 0.9987, 0.9989, 1);el.animate({ translate: ['0 0', '240px 0'] }, { duration: 715, easing: 'linear(0, 0.0079, 0.0297, 0.0629, 0.1049, 0.1539, 0.2078, 0.265, 0.3241, 0.384, 0.4434, 0.5017, 0.5581, 0.612, 0.6631, 0.711, 0.7554, 0.7964, 0.8337, 0.8675, 0.8978, 0.9247, 0.9484, 0.969, 0.9866, 1.0016, 1.0142, 1.0244, 1.0326, 1.039, 1.0437, 1.0469, 1.049, 1.0499, 1.0499, 1.0492, 1.0478, 1.0459, 1.0436, 1.041, 1.0383, 1.0353, 1.0324, 1.0294, 1.0264, 1.0235, 1.0208, 1.0181, 1.0157, 1.0134, 1.0112, 1.0093, 1.0075, 1.0059, 1.0044, 1.0032, 1.0021, 1.0011, 1.0003, 0.9996, 0.999, 0.9986, 0.9982, 0.9979, 0.9977, 0.9976, 0.9975, 0.9975, 0.9975, 0.9976, 0.9977, 0.9978, 0.9979, 0.998, 0.9982, 0.9983, 0.9985, 0.9986, 0.9987, 0.9989, 1)', fill: 'both' });import { spring, springDuration, springLinear } from '../../core/motion/springs.js';
const k = 210, d = 20;
// per-frame code (window.seek, vawe.onFrame): t is seconds since the move starts
const x = 240 * spring(t, k, d);
// CSS and Web Animations: 715 ms, the linear() string above
el.animate(
{ translate: ['0 0', '240px 0'] },
{ duration: springDuration(k, d) * 1000, easing: springLinear(k, d), fill: 'both' },
);Numbers
- Stiffness
- 210k, with mass 1
- Damping
- 20d, with mass 1
- Damping ratio
- 0.69underdamped
- Settle time
- 0.715 swithin 0.1% of the end
- Overshoot
- 5%peak at 0.3 s
- Crosses the end
- 2times
- 50% of travel
- 0.099 s14% of the settle time
- 90% of travel
- 0.18 s25% of the settle time
- Natural frequency
- 14.49 rad/ssqrt(k)
- Ring period
- 0.599 sone swing of the overshoot
- Peak speed
- 4.79xtimes the average speed
- linear() points
- 81within 0.19% of travel
Computed with spring() and springDuration() from core/motion/springs.js. The settle time is the last moment the spring is more than 0.1% away from the end value; a library stops its own spring by its own rest thresholds, so its clock can run shorter.
Source of the numbers
| react-spring | @react-spring/core 10.1.2 |
| config.stiff = { tension: 210, friction: 20 } | packages/core/src/constants.ts, const config |
Read it at github.com/pmndrs/react-spring/blob/main/packages/core/src/constants.ts.
Conversion: Stiffness is tension and damping is friction, with mass 1 (the default). The physics loop in the same package, acceleration = (-tension x displacement - friction x velocity) / mass, is the spring that spring() in springs.js solves.
Related springs
The four closest curves in this set, by the average gap between the two springs over their first seconds. A gap of 0.01 is invisible; 0.1 is a different feel.