6.0.4 • Published 5 years ago

react-swipe v6.0.4

Weekly downloads
35,270
License
MIT
Repository
github
Last release
5 years ago

react-swipe

build status npm version Download Count

Brad Birdsall's Swipe.js as a React component.

Demo

Check out the demo from a mobile device (real or emulated).

Install

npm install react swipe-js-iso react-swipe --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 one react-swipe will re-initiate underlying Swipe.js instance with fresh options

  • style: ?Object - object with 3 keys (see defaults):

    • container: ?Object
    • wrapper: ?Object
    • child: ?Object
  • regular props as className, id for root component are also supported

  • childCount: ?Number - use it to explicitely tell react-swipe that it needs to re-initiate underlying Swipe.js instance. For example, by setting the childCount prop to the length of the images array that you pass into react-swipe, re-rendering will take place when the images.length differs from the previous render 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

6.0.4

5 years ago

6.0.3

5 years ago

6.0.2

5 years ago

6.0.1

5 years ago

6.0.0

5 years ago

5.1.1

6 years ago

5.1.0

7 years ago

5.0.8

7 years ago

5.0.7

7 years ago

5.0.6

7 years ago

5.0.5

8 years ago

5.0.4

8 years ago

5.0.3

8 years ago

5.0.2

8 years ago

5.0.1

8 years ago

5.0.0

8 years ago

4.1.3

8 years ago

4.1.2

8 years ago

4.1.1

8 years ago

4.1.0

8 years ago

4.0.1

8 years ago

4.0.0

8 years ago

3.0.0

8 years ago

2.3.1

9 years ago

2.3.0

9 years ago

2.1.0

9 years ago

2.0.11

9 years ago

2.0.10

9 years ago

2.0.9

9 years ago

2.0.8

9 years ago

2.0.7

9 years ago

2.0.6

9 years ago

2.0.5

9 years ago

2.0.4

9 years ago

2.0.3

9 years ago

2.0.2

9 years ago

2.0.0

9 years ago

1.0.3

9 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago