Reputation: 105
If there is only one item or few items in ScrollView on Android, I won't get any event from onScorll
. In iOS, I still could get the event because the bounces
.
My problem is how could I listen to the scroll offset on Android with a list? I've tried PanResponder
, but in my case, I would like to detect the swipe down and up gesture in a vertical Flatlist
.
Upvotes: 3
Views: 911
Reputation: 105
In the end, I solved this problem by adding PanResponder
for FlatList
. When there are just few items, PanResponder
works fine. On the other hand, if there are many items, I can get the nativeEvent
from onScroll
.
Upvotes: 0
Reputation: 1939
Flatlist
is built internally using the responder
API, so if it doesn't do exactly what you want then you definitely can use PanResponder
.
If there is only a few items in your data array then the list can't scroll, so no scroll will be triggered.
If you are just trying to track a swipe gesture for example do dismiss something, that isn't really what Flatlist
was designed to solve, and you could use PanResponder
directly.
Upvotes: 1