Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-swipeable

Package Overview
Dependencies
Maintainers
2
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-swipeable - npm Package Compare versions

Comparing version 3.5.1 to 3.6.0

6

CHANGELOG.md

@@ -0,1 +1,5 @@

# 3.6.0
* add stopPropagation prop for all swipe events, defaults to `false`. See [#46](https://github.com/dogfessional/react-swipeable/issues/46) for more info.
# 3.5.1

@@ -11,3 +15,3 @@

* Add preventDefault while swiping when props `onSwipedLeft`, `onSwipedRight`, `onSwipedUp`, and `onSwipedDown` are present. See #21 and #37 for more info.
* Add preventDefault while swiping when props `onSwipedLeft`, `onSwipedRight`, `onSwipedUp`, and `onSwipedDown` are present. See [#21](https://github.com/dogfessional/react-swipeable/issues/21) and [#37](https://github.com/dogfessional/react-swipeable/pull/37) for more info.

@@ -14,0 +18,0 @@ # 3.3.0

24

lib/Swipeable.js

@@ -24,2 +24,3 @@ 'use strict';

preventDefaultTouchmoveEvent: React.PropTypes.bool,
stopPropagation: React.PropTypes.bool,
nodeName: React.PropTypes.string

@@ -42,2 +43,3 @@ },

preventDefaultTouchmoveEvent: true,
stopPropagation: false,
nodeName: 'div'

@@ -73,2 +75,5 @@ };

}
if (this.props.stopPropagation) e.stopPropagation();
this.setState({

@@ -94,2 +99,4 @@ start: Date.now(),

if (this.props.stopPropagation) e.stopPropagation();
if (this.props.onSwiping) {

@@ -132,21 +139,23 @@ this.props.onSwiping(e, pos.deltaX, pos.deltaY, pos.absX, pos.absY, pos.velocity);

touchEnd: function touchEnd(ev) {
touchEnd: function touchEnd(e) {
if (this.state.swiping) {
var pos = this.calculatePos(ev);
var pos = this.calculatePos(e);
if (this.props.stopPropagation) e.stopPropagation();
var isFlick = pos.velocity > this.props.flickThreshold;
this.props.onSwiped && this.props.onSwiped(ev, pos.deltaX, pos.deltaY, isFlick);
this.props.onSwiped && this.props.onSwiped(e, pos.deltaX, pos.deltaY, isFlick, pos.velocity);
if (pos.absX > pos.absY) {
if (pos.deltaX > 0) {
this.props.onSwipedLeft && this.props.onSwipedLeft(ev, pos.deltaX, isFlick);
this.props.onSwipedLeft && this.props.onSwipedLeft(e, pos.deltaX, isFlick);
} else {
this.props.onSwipedRight && this.props.onSwipedRight(ev, pos.deltaX, isFlick);
this.props.onSwipedRight && this.props.onSwipedRight(e, pos.deltaX, isFlick);
}
} else {
if (pos.deltaY > 0) {
this.props.onSwipedUp && this.props.onSwipedUp(ev, pos.deltaY, isFlick);
this.props.onSwipedUp && this.props.onSwipedUp(e, pos.deltaY, isFlick);
} else {
this.props.onSwipedDown && this.props.onSwipedDown(ev, pos.deltaY, isFlick);
this.props.onSwipedDown && this.props.onSwipedDown(e, pos.deltaY, isFlick);
}

@@ -179,2 +188,3 @@ }

delete newProps.preventDefaultTouchmoveEvent;
delete newProps.stopPropagation;
delete newProps.nodeName;

@@ -181,0 +191,0 @@ delete newProps.children;

{
"name": "react-swipeable",
"version": "3.5.1",
"version": "3.6.0",
"description": "Swipe bindings for react",

@@ -5,0 +5,0 @@ "main": "lib/Swipeable.js",

@@ -18,2 +18,3 @@ const React = require('react')

preventDefaultTouchmoveEvent: React.PropTypes.bool,
stopPropagation: React.PropTypes.bool,
nodeName: React.PropTypes.string

@@ -36,2 +37,3 @@ },

preventDefaultTouchmoveEvent: true,
stopPropagation: false,
nodeName: 'div'

@@ -67,2 +69,5 @@ }

}
if (this.props.stopPropagation) e.stopPropagation()
this.setState({

@@ -88,2 +93,4 @@ start: Date.now(),

if (this.props.stopPropagation) e.stopPropagation()
if (this.props.onSwiping) {

@@ -126,13 +133,16 @@ this.props.onSwiping(e, pos.deltaX, pos.deltaY, pos.absX, pos.absY, pos.velocity)

touchEnd: function (ev) {
touchEnd: function (e) {
if (this.state.swiping) {
const pos = this.calculatePos(ev)
const pos = this.calculatePos(e)
if (this.props.stopPropagation) e.stopPropagation()
const isFlick = pos.velocity > this.props.flickThreshold
this.props.onSwiped && this.props.onSwiped(
ev,
e,
pos.deltaX,
pos.deltaY,
isFlick
isFlick,
pos.velocity
)

@@ -142,11 +152,11 @@

if (pos.deltaX > 0) {
this.props.onSwipedLeft && this.props.onSwipedLeft(ev, pos.deltaX, isFlick)
this.props.onSwipedLeft && this.props.onSwipedLeft(e, pos.deltaX, isFlick)
} else {
this.props.onSwipedRight && this.props.onSwipedRight(ev, pos.deltaX, isFlick)
this.props.onSwipedRight && this.props.onSwipedRight(e, pos.deltaX, isFlick)
}
} else {
if (pos.deltaY > 0) {
this.props.onSwipedUp && this.props.onSwipedUp(ev, pos.deltaY, isFlick)
this.props.onSwipedUp && this.props.onSwipedUp(e, pos.deltaY, isFlick)
} else {
this.props.onSwipedDown && this.props.onSwipedDown(ev, pos.deltaY, isFlick)
this.props.onSwipedDown && this.props.onSwipedDown(e, pos.deltaY, isFlick)
}

@@ -180,2 +190,3 @@ }

delete newProps.preventDefaultTouchmoveEvent
delete newProps.stopPropagation
delete newProps.nodeName

@@ -182,0 +193,0 @@ delete newProps.children

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc