Search code snippets, questions, articles...

Custom Corousal

onScroll = (event) => {
 const activeIndex = Math.round(event.nativeEvent.contentOffset.x / wp(100));
 if (this.state.activeIndex !== activeIndex) {
   this.setState({ activeIndex });
 }
};



<ScrollView
 horizontal={true}
 style={styles.container}
 snapToInterval={wp(100)}
 decelerationRate={0}
 scrollEventThrottle={16}
 onScroll={this.onScroll}
 snapToAlignment={'center'}
 showsHorizontalScrollIndicator={false}>

 </ScrollView>
Was this helpful?
0 Comments
Programming Feeds
Learn something new everyday on Devsheet