0.0.23 • Published 1 year ago

react-easy-swipe v0.0.23

Weekly downloads
144,239
License
MIT
Repository
github
Last release
1 year 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-carouselfree-assessment-react18gcc-atoms-packageeusmile-assessment-react17eusmile-assessment-react18@helms/weda-uiinv-eu-smile-assessmentlumin-nextnpm-test-module-boilerplatemobile-calendar-testmodified-react-responsive-carouselmoda-web-librarymobile-gcc-atoms-packagenuorder-carouselnuorder-react-carouselopificio-cmsmaterial-ui-carouselreact-blake-carouselreact-responsive-sliderreact-responsive-carouselreact-responsive-carousel-2react-responsive-carousel-3react-responsive-carousel-customreact-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-overflow-scrollingproto-guidelinereact-base-guidereact-carousel-minimalreact-carousel-minimal-nextstoreberry-ui-components-betastoreberry-ui-components-test-onestoreberry-ui-componentsunsafe-bc-react-componentswebmotors.catalogo.uivernost_common_componentyar-carousel@adactiveasia/react-responsive-carousel@admin-layout/timetracker-module-browser@wwchen412/react-responsive-carousel@tjjjwxzq/react-responsive-carousel@vinhnguyen/react-responsive-carousel@prom-ui/core@zijiezhou/weda-uiaizk-ui-reactaor-pkg-testboxabl-react-carouselbuoy-carouselappybeesitebasedesign-iswad@concrete-design/core@camfolio/react-responsive-carousel@cybergab/gab-react-responsive-carousel@techychan/react-responsive-carousel@cloudbase/weda-ui@duchesstoffee/react-responsive-carousel@evo/swipe-gallery@evo/projects@habx/lib-design-system@habx/ui-core@lbrdan/myriorama@rizedr/react-responsive-carousel@redisrupt/react-responsive-carousel@maxwellgordon/react-responsive-carousel-with-carousel-prop-type@mohammedsrehan/react-responsive-carousel@mikemmb73/react-responsive-carousel2@linqto-team/react-responsive-carousel@sambego/diorama@hurtigruten/shared-components@instak/react-responsive-carousel@infinitebrahmanuniverse/nolb-react-eacheeseburger-menu
0.0.23

1 year ago

0.0.22

3 years ago

0.0.21

4 years ago

0.0.20

4 years ago

0.0.19

4 years ago

0.0.18

5 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago