View-Pager/Slider/Carousel powered by React Motion.
Note before using
Use at your own risk, API's are subject to change. It's been fairly stable these last few months, but still might change slightly. Once the outstanding issues are fixed I will release 1.0.0.
Usage
yarn add react-view-pager
npm install react-view-pager --save
<script src="https://unpkg.com/react-view-pager/dist/react-view-pager.js"></script>(UMD library exposed as `ReactViewPager`)
The number of views visible in the frame at one time. Defaults to 1. Use auto to respect the views's natural or defined dimensions.
viewsToMove: PropTypes.number
The number of views to move upon using prev and next methods. Defaults to 1.
align: PropTypes.number
Pass any number to offset the view from the start of the track. For example, 0 aligns to the start of the track, 0.5 to the center, and 1 aligns to the end.
contain: PropTypes.bool
Prevents empty space from showing in frame. Defaults to false.
infinite: PropTypes.bool
Prepare your pager for intergalactic space travel. Allows the track to wrap to the beginning/end when moving to a view. To infinity and beyond!
instant: PropTypes.bool
Move to a view instantly without any animation. This will control the internal instant state inside of the component.
axis: PropTypes.oneOf(['x', 'y'])
Which axis the track moves on. Defaults to x.
animations: PropTypes.array
Define a limitless array of animation stops. Each object in the array requires a prop and stops property along with an optional unit property.
// scale and fade views as they enter and leaveconst animations = [{ prop: 'scale', stops: [ [-200, 0.85], [0, 1], [200, 0.85] ]}, { prop: 'opacity', stops: [ [-200, 0.15], [0, 1], [200, 0.15] ]}]