React-Native Horizontal Scroll View Pagination: Preview Next Page/Card

Johannes Filter picture Johannes Filter · Apr 4, 2017 · Viewed 38.2k times · Source

I want to to a horizontal ScrollView with pagination enabled with one special requirement: each page (or card) is 90% of the container wide. The remaining 10% should be a preview of the next page.

It is possible to do this with ScrollView? Can I somehow specify the width of the pagination instead of taking the width of the container?

Carousel (image taken from this similar question: React Native Card Carousel view?)

Answer

Vasil Enchev picture Vasil Enchev · Aug 3, 2017

I spend a lot of time fighting with this until I figured it out so here is my solution if it helps someone.

https://snack.expo.io/H1CnjIeDb

Problem was all these were required and pagination should be turned off

horizontal={true}
decelerationRate={0}
snapToInterval={width - 60}
snapToAlignment={"center"}