Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native Android ScrollView can't get event from onScroll

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.

like image 509
JH Lin Avatar asked Apr 19 '26 06:04

JH Lin


1 Answers

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.

like image 123
Travis James Avatar answered Apr 21 '26 21:04

Travis James



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!