0.0.23 • Published 2 years ago

react-easy-swipe v0.0.23

Weekly downloads
144,239
License
MIT
Repository
github
Last release
2 years ago

REACT EASY SWIPE

FOSSA Status

Add swipe interactions to your react component.

Demo

http://leandrowd.github.io/react-easy-swipe/

  • Open your console;
  • Swipe over the content and check your console;
  • This is a touch component so make sure your browser is emulating touch.

Tips:

1) To prevent scroll during swipe, return true from the handler passed to onSwipeMove

2) To allow mouse events to behave like touch, pass a prop allowMouseEvents

3) To prevent accidental swipes on scroll, pass a prop tolerance with the tolerance pixel as number.

Instalation

npm install react-easy-swipe --save

Usage

import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import Swipe from 'react-easy-swipe';

class MyComponent extends Component {
  onSwipeStart(event) {
    console.log('Start swiping...', event);
  }

  onSwipeMove(position, event) {
    console.log(`Moved ${position.x} pixels horizontally`, event);
    console.log(`Moved ${position.y} pixels vertically`, event);
  }

  onSwipeEnd(event) {
    console.log('End swiping...', event);
  }

  render() {
    const boxStyle = {
      width: '100%',
      height: '300px',
      border: '1px solid black',
      background: '#ccc',
      padding: '20px',
      fontSize: '3em'
    };

    return (
      <Swipe
        onSwipeStart={this.onSwipeStart}
        onSwipeMove={this.onSwipeMove}
        onSwipeEnd={this.onSwipeEnd}>
          <div style={boxStyle}>Open the console and swipe me</div>
      </Swipe>
    );
  }
}

ReactDOM.render(<MyComponent/>, document.getElementById('root'));

Properties

{
  tagName: PropTypes.string,
  className: PropTypes.string,
  style: PropTypes.object,
  children: PropTypes.node,
  allowMouseEvents: PropTypes.bool,
  onSwipeUp: PropTypes.func,
  onSwipeDown: PropTypes.func,
  onSwipeLeft: PropTypes.func,
  onSwipeRight: PropTypes.func,
  onSwipeStart: PropTypes.func,
  onSwipeMove: PropTypes.func,
  onSwipeEnd: PropTypes.func,
  tolerance: PropTypes.number.isRequired
}

Contributing

Please, feel free to contribute. You may open a bug, request a feature, submit a pull request or whatever you want!

License

FOSSA Status

react-responsive-carousel-editreactnodejs32-react-carouselcoursebe-guidelinecallmd-guideline@clockbook-app/timetracker-module-browser@everything-registry/sub-chunk-2552@gumbee/react-responsive-carouselstoreberry-ui-componentsstoreberry-ui-components-betastoreberry-ui-components-test-one@concrete-design/core@cybergab/gab-react-responsive-carousel@camfolio/react-responsive-carousel@helms/weda-uireact-carousel-extended@admin-layout/timetracker-module-browser@cloudbase/weda-ui@adactiveasia/react-responsive-carouselyar-carouselwebmotors.catalogo.uiunsafe-bc-react-componentsvernost_common_component@sambego/diorama@duchesstoffee/react-responsive-carousel@habx/lib-design-system@habx/ui-core@hurtigruten/shared-components@infinitebrahmanuniverse/nolb-react-ea@instak/react-responsive-carousel@lbrdan/myriorama@linqto-team/react-responsive-carousel@evo/projects@evo/swipe-gallery@maxwellgordon/react-responsive-carousel-with-carousel-prop-type@mikemmb73/react-responsive-carousel2@mohammedsrehan/react-responsive-carousel@prom-ui/core@redisrupt/react-responsive-carousel@rizedr/react-responsive-carouselmobile-gcc-atoms-packagemobile-calendar-testmodified-react-responsive-carouselmoda-web-libraryopificio-cmsnpm-test-module-boilerplatenuorder-carouselnuorder-react-carouselreact-carousel-minimalreact-carousel-minimal-nextreact-blake-carouselreact-base-guideproto-guidelinereact-overflow-scrollingreact-responsive-sliderreact-responsive-carousel-custom2react-responsive-carousel-forkreact-responsive-carousel-nuggetreact-responsive-carousel-optunereact-responsive-carousel-projectreact-responsive-carousel-up-downreact-responsive-carousel-usreact-responsive-carousel-v2react-responsive-carousel-variable-heightreact-responsive-carousel-vfixreact-sliding-carouselreact-responsive-carouselreact-responsive-carousel-2react-responsive-carousel-3react-responsive-carousel-custominv-eu-smile-assessmentlumin-nextmaterial-ui-carousel@wwchen412/react-responsive-carousel@tjjjwxzq/react-responsive-carousel@vinhnguyen/react-responsive-carousel@techychan/react-responsive-carousel@zijiezhou/weda-uiaizk-ui-reactaor-pkg-testappybeesitecheeseburger-menubasedesign-iswadbuoy-carouselboxabl-react-carouseleusmile-assessment-react17eusmile-assessment-react18free-assessment-react18gcc-atoms-package
0.0.23

2 years ago

0.0.22

4 years ago

0.0.21

5 years ago

0.0.20

5 years ago

0.0.19

5 years ago

0.0.18

6 years ago

0.0.17

7 years ago

0.0.16

7 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago