How to snap to the adjacent view no matter how hard you scroll in react native?

Viewed 47

I made a Scroll View like this:

<ScrollView horizontal={true} snapToInterval={ScreenWidth} decelerationRate="fast" snapToAlignment={"center"}>
  <View style={{width:Screen}}>...</View>
  <View style={{width:Screen}}>...</View>
  <View style={{width:Screen}}>...</View>
</ScrollView>

but if I scroll/swipe it too fast this happens (it directly goes to the last View)
but I want this to happen no matter how fast they swipe (it goes only to the adjacent View)

1 Answers

I solved it

all I had to do was use disableIntervalMomentum={true}

<ScrollView horizontal={true} snapToInterval={ScreenWidth} decelerationRate="fast" disableIntervalMomentum={true}>
  <View style={{width:Screen}}>...</View>
  <View style={{width:Screen}}>...</View>
  <View style={{width:Screen}}>...</View>
</ScrollView>
Related