Hi I am trying to achieve scrollview
snap to center
like below gif
link
Check This Gif
But unable to do so. Following is my react nat
If you don't want to use snapToInterval because of the misalignment for long lists you can use snapToOffsets which is more precise.
for example:
const { width } = Dimensions.get('window');
this.IMAGE_WIDTH = width * (1 / 2.5)
this.image_margin = 5
this.nishhar = width - ((this.IMAGE_WIDTH + this.image_margin) * 2 + this.image_margin * 2)
dataNum = [1, 2, 3, 4, 5, 6]
return ( {
return (
)
}}
keyExtractor={this.keyGenerator}
horizontal={true}
snapToAlignment={"start"}
snapToOffsets={[...Array(dataNum.length)].map((x, i) => (i * (this.IMAGE_WIDTH + 2 * this.image_margin) - (this.nishhar * 0.5)))}
decelerationRate={"fast"}
pagingEnabled
/>)
or you can also checkout this example: https://snack.expo.io/SyWXFqDAB