react-spring
react-spring copied to clipboard
'onRest' not fired when two 'start' calls are too close
🐛 Bug Report
To Reproduce
I use the spring API like this:
const [props, api] = useSpring(() => ({
opacity: 0,
onRest: {
opacity: (v) => {
if (v.value === 0) {
// do something
}
},
},
}));
Then user interaction will start opacity animation between value 0~1.
// user trigger
api.start({ opacity: 1 });
// user untrigger
api.start({ opacity: 0 });
When users move too fast, the trigger ---> untrigger calls are too close, e.g. about less than a single animation frame, the onRest sometimes will not called.
Expected behavior
onRest be called whenever start is called, even when 2 start calls are too close.
Link to repro
https://codesandbox.io/s/tippy-js-react-spring-forked-hl3vd?file=/src/App.js
The button click simulates the 2 close start calls. Sometimes console log will not show, (the click count is not equal to the log count)
Environment
react-springv9.3.1reactv17.0.2