rgommezz / react-native-scroll-bottom-sheet

Cross platform scrollable bottom sheet with virtualisation support, native animations at 60 FPS and fully implemented in JS land :fire:
MIT License
1.55k stars 67 forks source link

Allow snapTo to interrupt previous animation #46

Closed AppKidd closed 4 years ago

AppKidd commented 4 years ago

Current Behavior

If you invoke snapTo before the previous animation is finished (before onSettle), nothing will happen.

Expected Behavior

The ongoing animation should stop, and the new snapTo should begin. Animations can take a few hundred ms before state.finished is updated. For example, if I open a sheet, drag it around, and then immediately try to dismiss it via snapTo, often the first attempt to dismiss will be ignored.

How to reproduce

Invoke snapTo when an existing animation is running before it has fully settled.

Your Environment

version
Platform (Android, iOS or both) both
react-native-scroll-bottom-sheet 0.7.0
react-native 0.62.2
react-native-gesture-handler 1.6.1
react-native-reanimated 1.9.0
AppKidd commented 4 years ago

Increasing the restDisplacementThreshold and restSpeedThreshold has significantly reduced the severity of this. Ongoing animations now settle faster, meaning we see this issue much less often.