How do I know the scroll state in a FlatList?

How do I know the scroll state in a FlatList? For example, startScroll, Scrolling, endScroll

<FlatList
    onScroll={(e) => { }}
/>

      

there is an onScroll mothed, but it only starts when scrolling. I want to listen to the start and end of the scroll, how can I do that?

I also tried using TouchableWithoutFeedback:

<TouchableWithoutFeedback
    onPressIn={() => console.log('in')}
    onPressOut={() => console.log('out')}>
    <View><FlatList/></View>
</TouchableWithoutFeedback>

      

But touch events will be intercepted by TouchableWithoutFeedback, FlatList cannot be scrolled.

+3


source to share


1 answer


since Flatlist

inherits all the details ScrollView

, you can use onScrollEndDrag

and onScrollBeginDrag

to solve this problem:

<FlatList
    onScrollEndDrag={() => console.log("end")}
    onScrollBeginDrag={() => console.log("start")}/>

      



additional information .

+6


source







All Articles