Make sure that `onSnapToItem` is triggered AFTER scroll animation's completion
See original GitHub issueCurrently, React Native doesn’t provide a callback for the scrollTo()
method, which is a bummer.
The ScrollView component has a prop onScrollAnimationEnd
, but unfortunately this works on iOS only (even though it is referenced in the Java file). Moreover, a bug currently prevents the callback from being fired with horizontal scrollers.
Another lead would be to link the duration of the scroll animation to a timer before firing the callback. Unfortunately, scrollTo()
doesn’t accept a custom duration.
An idea might be to activate momentum events on Android and see if onMomentumScrollEnd
can provide a good enough feedback without impairing performance too much. But this event might not be fired when snapping programatically… Moreover, it is automatically enabled if a momentum callback has been set.
ScrollResponder is another lead worth pursuing…
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:9 (6 by maintainers)
Top GitHub Comments
@bd-arc thank you very much for you attention, component very nice.
@piuccio @joseygordev Version 2.2.1 should resolve your issue with the faulty index.
I’ve completely refactored the way callbacks are handled when momentum is disabled. Let’s face it: this is hacky since
ScrollView
neither provides callbacks to thescrollTo
method nor gives access to aonScrollEnd
event.Make sure to play with the new props
scrollEndDragThrottleValue
andsnapCallbackDebounceValue
. Let me know how this works for you.