Reputation: 789
I'm using a Horizontal ScrollVIew with paging in react native, I'm trying to recreate the coverflow view like Spotify. visually is perfect however I want to call a function when paging left or right, like playNext or playPrev. is there a way to listen to the paging event and direction?
<ScrollView pagingEnabled={true} horizontal={true}>
<CoverFlowItem page_width={D.width} width={width} height={height}
source={{uri: current.poster}}/>
.....
</ScrollView>
Upvotes: 0
Views: 8806
Reputation: 694
https://facebook.github.io/react-native/docs/scrollview#pagingenabled
With this props, you'll get the pagination you want. To get which way its going, you component will need to save the offset each time you scroll. use the props: onScroll
, onScrollBeginDrag
and/or onScrollEndDrag
to access the current offset of the scroll. With it, and the one previously saved, you can determine which way the scroll is going
Upvotes: 1