How to know the state of scroll in FlatList? Such as startScroll、Scrolling、endScroll
<FlatList
onScroll={(e) => { }}
/>
there is onScroll mothed,but it only run when Scrolling. I want to listen scroll start and end,how can i do ?
I also tried use TouchableWithoutFeedback:
<TouchableWithoutFeedback
onPressIn={() => console.log('in')}
onPressOut={() => console.log('out')}>
<View><FlatList/></View>
</TouchableWithoutFeedback>
But touch events will be intercepted by TouchableWithoutFeedback, FlatList can't scroll.
To get the current scroll position of ScrollView in React Native, we can set the onScroll prop of the ScrollView to a function that takes the scroll event object as an argument.
To scroll to end of FlatList after displaying the keyboard with React Native, we can set the onLayour prop to a function that calls scrollToEnd on the FlatList's ref. to set onLayout to a function that calls flatListRef. current. scrollToEnd to scroll the FlatList to the end.
Flatlist: The FlatList Component is an inbuilt react-native component that displays similarly structured data in a scrollable list. It shows only those elements that are currently being displayed on the screen.
In Flatlist set scrollsToTop={false} this will retain position when you navigate back from detail screen. I am using Expo version 25.
since Flatlist
inherits all ScrollView
props, you can use onScrollEndDrag
and onScrollBeginDrag
to solve this issue:
<FlatList
onScrollEndDrag={() => console.log("end")}
onScrollBeginDrag={() => console.log("start")}/>
further information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With