Horizontal scrollview snapping react native

前端 未结 4 1980
臣服心动
臣服心动 2021-01-31 09:19

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

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-31 10:02

    You don't need other libraries you can do that with ScrollView. All you need is to add the following props in your component.

        horizontal= {true}
        decelerationRate={0}
        snapToInterval={200} //your element width
        snapToAlignment={"center"}
    

    Check this snack for more details on how to implement it https://snack.expo.io/H1CnjIeDb

提交回复
热议问题