react-swipe-fork
v6.0.6
Published
Brad Birdsall's Swipe.js as a React component
Downloads
3
Maintainers
Readme
Just another fork of react-swipe
Demo
Check out the demo from a mobile device (real or emulated).
Install
npm install react swipe-js-iso-fork react-swipe-fork --save
Usage
Examples
import React from 'react';
import ReactDOM from 'react-dom';
import ReactSwipe from 'react-swipe';
const Carousel = () => {
let reactSwipeEl;
return (
<div>
<ReactSwipe
className="carousel"
swipeOptions={{ continuous: false }}
ref={el => (reactSwipeEl = el)}
>
<div>PANE 1</div>
<div>PANE 2</div>
<div>PANE 3</div>
</ReactSwipe>
<button onClick={() => reactSwipeEl.next()}>Next</button>
<button onClick={() => reactSwipeEl.prev()}>Previous</button>
</div>
);
};
ReactDOM.render(<Carousel />, document.getElementById('app'));
Props
swipeOptions: ?Object
- supports all original options from Swipe.js config. If passed object differs from the previous onereact-swipe
will re-initiate underlying Swipe.js instance with fresh optionsstyle: ?Object
- object with 3 keys (see defaults):container: ?Object
wrapper: ?Object
child: ?Object
regular props as
className
,id
for root component are also supportedchildCount: ?Number
- use it to explicitely tellreact-swipe
that it needs to re-initiate underlying Swipe.js instance. For example, by setting thechildCount
prop to thelength
of the images array that you pass intoreact-swipe
, re-rendering will take place when theimages.length
differs from the previousrender
pass:
<ReactSwipe childCount={images.length}>{images}</ReactSwipe>
Methods
Component proxies all Swipe.js instance methods.
Playground
Configure the ReactSwipe component in a sandbox environment at CodeSandbox.
MIT Licensed