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

react-swipeable

Package Overview
Dependencies
Maintainers
1
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 1.0.0 to 1.1.0

2

package.json
{
"name": "react-swipeable",
"version": "1.0.0",
"version": "1.1.0",
"description": "Swipe bindings for react",

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

var React = require('react')
var FLICK_THRESHOLD = 0.3
var Swipeable = React.createClass({
propTypes: {
onSwiped: React.PropTypes.func,
onFlick: React.PropTypes.func,
onSwipingUp: React.PropTypes.func,

@@ -17,3 +20,4 @@ onSwipingRight: React.PropTypes.func,

y: null,
swiping: false
swiping: false,
start: 0
}

@@ -51,2 +55,3 @@ },

this.setState({
start: Date.now(),
x: e.touches[0].clientX,

@@ -66,3 +71,3 @@ y: e.touches[0].clientY,

if (pos.absX < this.props.delta && pos.abxY < this.props.delta) {
if (pos.absX < this.props.delta && pos.absY < this.props.delta) {
return

@@ -107,3 +112,12 @@ }

var pos = this.calculatePos(e)
this.props.onSwiped && this.props.onSwiped(e, pos.absX, pos.abxY)
var time = Date.now() - this.state.start
var distance = pos.absX + pos.absY
var isFlick = (time / distance) > FLICK_THRESHOLD
if (isFlick) {
this.props.onFlick && this.props.onFlick(e, pos.deltaX, pos.deltaY)
} else {
this.props.onSwiped && this.props.onSwiped(e, pos.absX, pos.absY)
}
}

@@ -110,0 +124,0 @@ this.setState(this.getInitialState())

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