react-easy-swipe

WebJar for react-easy-swipe

License

License

MIT
Categories

Categories

React User Interface Web Frameworks
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

react-easy-swipe
Last Version

Last Version

0.0.16
Release Date

Release Date

Type

Type

jar
Description

Description

react-easy-swipe
WebJar for react-easy-swipe
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/leandrowd/react-easy-swipe

Download react-easy-swipe

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/react-easy-swipe/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>react-easy-swipe</artifactId>
    <version>0.0.16</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/react-easy-swipe/
implementation 'org.webjars.npm:react-easy-swipe:0.0.16'
// https://jarcasting.com/artifacts/org.webjars.npm/react-easy-swipe/
implementation ("org.webjars.npm:react-easy-swipe:0.0.16")
'org.webjars.npm:react-easy-swipe:jar:0.0.16'
<dependency org="org.webjars.npm" name="react-easy-swipe" rev="0.0.16">
  <artifact name="react-easy-swipe" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='react-easy-swipe', version='0.0.16')
)
libraryDependencies += "org.webjars.npm" % "react-easy-swipe" % "0.0.16"
[org.webjars.npm/react-easy-swipe "0.0.16"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : prop-types jar [15.5.8,16)

Project Modules

There are no modules declared in this project.

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

Versions

Version
0.0.16
0.0.13