react-swipe-events
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -103,3 +103,2 @@ (function (global, factory) { | ||
_this.onTouchEnd = _this.onTouchEnd.bind(_this); | ||
_this.getScreenOffset = _this.getScreenOffset.bind(_this); | ||
_this.getModifiedProps = _this.getModifiedProps.bind(_this); | ||
@@ -132,16 +131,11 @@ _this.getDelta = _this.getDelta.bind(_this); | ||
var current = this.getCurrentPosition(touch); | ||
var screenOffset = this.getScreenOffset(); | ||
if (Math.abs(delta.x) > this.props.threshold) { | ||
if (this.state.originalX < screenOffset.x) { | ||
if (delta.x > 0) this.props.onSwipedRight && this.props.onSwipedRight(e, this.state.originalX, current.x); | ||
if (delta.x < 0) this.props.onSwipedLeft && this.props.onSwipedLeft(e, this.state.originalX, current.x); | ||
} | ||
if (delta.x > 0) this.props.onSwipedRight && this.props.onSwipedRight(e, this.state.originalX, current.x); | ||
if (delta.x < 0) this.props.onSwipedLeft && this.props.onSwipedLeft(e, this.state.originalX, current.x); | ||
} | ||
if (Math.abs(delta.y) > this.props.threshold) { | ||
if (this.state.originalY < screenOffset.y) { | ||
if (delta.y > 0) this.props.onSwipedDown && this.props.onSwipedDown(e, this.state.originalY, current.y); | ||
if (delta.y < 0) this.props.onSwipedUp && this.props.onSwipedUp(e, this.state.originalY, current.y); | ||
} | ||
if (delta.y > 0) this.props.onSwipedDown && this.props.onSwipedDown(e, this.state.originalY, current.y); | ||
if (delta.y < 0) this.props.onSwipedUp && this.props.onSwipedUp(e, this.state.originalY, current.y); | ||
} | ||
@@ -153,10 +147,2 @@ | ||
}, { | ||
key: 'getScreenOffset', | ||
value: function getScreenOffset() { | ||
return { | ||
x: this.props.screenXOffset || 0, | ||
y: this.props.screenYOffset || 0 | ||
}; | ||
} | ||
}, { | ||
key: 'getCurrentPosition', | ||
@@ -187,4 +173,2 @@ value: function getCurrentPosition(touch) { | ||
delete props.children; | ||
delete props.screenXOffset; | ||
delete props.screenYOffset; | ||
delete props.onSwiping; | ||
@@ -219,4 +203,2 @@ delete props.onSwiped; | ||
children: _react2.default.PropTypes.element.isRequired, | ||
screenXOffset: _react2.default.PropTypes.number, | ||
screenYOffset: _react2.default.PropTypes.number, | ||
onSwiping: _react2.default.PropTypes.func, | ||
@@ -223,0 +205,0 @@ onSwiped: _react2.default.PropTypes.func, |
120
package.json
{ | ||
"name": "react-swipe-events", | ||
"version": "1.0.1", | ||
"description": "Swipe (Touch) event for react component", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/iamham/react-swipe-events" | ||
}, | ||
"author": "Sarun Peetasai", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/iamham/react-swipe-events/issues" | ||
}, | ||
"homepage": "https://github.com/iamham/react-swipe-events", | ||
"keywords": [ | ||
"react-component", | ||
"react", | ||
"swipe", | ||
"touch", | ||
"event" | ||
], | ||
"options": { | ||
"mocha": "--require scripts/mocha_runner src/**/__tests__/**/*.js" | ||
}, | ||
"scripts": { | ||
"prepublish": "babel --plugins transform-es2015-modules-umd src --ignore __tests__ --out-dir ./dist", | ||
"lint": "eslint ./src", | ||
"lintfix": "eslint ./src --fix", | ||
"testonly": "mocha $npm_package_options_mocha", | ||
"test": "npm run lint && npm run testonly", | ||
"test-watch": "npm run testonly -- --watch --watch-extensions js" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.6.4", | ||
"babel-core": "^6.7.4", | ||
"babel-eslint": "^6.0.2", | ||
"babel-plugin-transform-es2015-modules-umd": "^6.6.5", | ||
"babel-polyfill": "^6.7.4", | ||
"babel-preset-es2015": "^6.6.0", | ||
"babel-preset-react": "^6.5.0", | ||
"babel-preset-stage-2": "^6.5.0", | ||
"chai": "^3.5.0", | ||
"enzyme": "^2.2.0", | ||
"eslint": "^2.7.0", | ||
"eslint-plugin-babel": "^3.1.0", | ||
"eslint-plugin-react": "^4.2.3", | ||
"jsdom": "^8.1.0", | ||
"mocha": "^2.4.5", | ||
"nodemon": "^1.9.1", | ||
"react-addons-test-utils": "^15.0.0", | ||
"react": "^15.0.0", | ||
"react-dom": "^15.0.0", | ||
"sinon": "^1.17.3" | ||
}, | ||
"peerDependencies": { | ||
"react": "~0.14.8 || ^15.0.0", | ||
"react-dom": "~0.14.8 || ^15.0.0" | ||
}, | ||
"dependencies": { | ||
"babel-runtime": "^6.6.1" | ||
} | ||
"name": "react-swipe-events", | ||
"version": "1.0.2", | ||
"description": "Swipe (Touch) event for react component", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/iamham/react-swipe-events" | ||
}, | ||
"author": "Sarun Peetasai", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/iamham/react-swipe-events/issues" | ||
}, | ||
"homepage": "https://github.com/iamham/react-swipe-events", | ||
"keywords": [ | ||
"react-component", | ||
"react", | ||
"swipe", | ||
"touch", | ||
"event" | ||
], | ||
"options": { | ||
"mocha": "--require scripts/mocha_runner src/**/__tests__/**/*.js" | ||
}, | ||
"scripts": { | ||
"prepublish": "babel --plugins transform-es2015-modules-umd src --ignore __tests__ --out-dir ./dist", | ||
"lint": "eslint ./src", | ||
"lintfix": "eslint ./src --fix", | ||
"testonly": "mocha $npm_package_options_mocha", | ||
"test": "npm run lint && npm run testonly", | ||
"test-watch": "npm run testonly -- --watch --watch-extensions js" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.6.4", | ||
"babel-core": "^6.7.4", | ||
"babel-eslint": "^6.0.2", | ||
"babel-plugin-transform-es2015-modules-umd": "^6.6.5", | ||
"babel-polyfill": "^6.7.4", | ||
"babel-preset-es2015": "^6.6.0", | ||
"babel-preset-react": "^6.5.0", | ||
"babel-preset-stage-2": "^6.5.0", | ||
"chai": "^3.5.0", | ||
"enzyme": "^2.2.0", | ||
"eslint": "^2.7.0", | ||
"eslint-plugin-babel": "^3.1.0", | ||
"eslint-plugin-react": "^4.2.3", | ||
"jsdom": "^8.1.0", | ||
"mocha": "^2.4.5", | ||
"nodemon": "^1.9.1", | ||
"react-addons-test-utils": "^15.0.0", | ||
"react": "^15.0.0", | ||
"react-dom": "^15.0.0", | ||
"sinon": "^1.17.3" | ||
}, | ||
"peerDependencies": { | ||
"react": "~0.14.8 || ^15.0.0", | ||
"react-dom": "~0.14.8 || ^15.0.0" | ||
}, | ||
"dependencies": { | ||
"babel-runtime": "^6.6.1" | ||
} | ||
} |
# ReactSwipeEvents: React Swipe (Touch Event) enabler | ||
https://www.npmjs.com/package/react-swipe-events | ||
@@ -14,3 +15,2 @@ This package is based on React-NPM-Boilerplate (https://github.com/juliancwirko/react-npm-boilerplate) | ||
Cover your component with ReactSwipeEvents | ||
- <ReactSwipeEvents><div></div></ReactSwipeEvents> | ||
@@ -17,0 +17,0 @@ ## Props |
@@ -12,3 +12,2 @@ import React from 'react' | ||
this.onTouchEnd = this.onTouchEnd.bind(this) | ||
this.getScreenOffset = this.getScreenOffset.bind(this) | ||
this.getModifiedProps = this.getModifiedProps.bind(this) | ||
@@ -36,16 +35,11 @@ this.getDelta = this.getDelta.bind(this) | ||
const current = this.getCurrentPosition(touch) | ||
const screenOffset = this.getScreenOffset() | ||
if (Math.abs(delta.x) > this.props.threshold) { | ||
if (this.state.originalX < screenOffset.x) { | ||
if (delta.x > 0) this.props.onSwipedRight && this.props.onSwipedRight(e, this.state.originalX, current.x) | ||
if (delta.x < 0) this.props.onSwipedLeft && this.props.onSwipedLeft(e, this.state.originalX, current.x) | ||
} | ||
if (delta.x > 0) this.props.onSwipedRight && this.props.onSwipedRight(e, this.state.originalX, current.x) | ||
if (delta.x < 0) this.props.onSwipedLeft && this.props.onSwipedLeft(e, this.state.originalX, current.x) | ||
} | ||
if (Math.abs(delta.y) > this.props.threshold) { | ||
if (this.state.originalY < screenOffset.y) { | ||
if (delta.y > 0) this.props.onSwipedDown && this.props.onSwipedDown(e, this.state.originalY, current.y) | ||
if (delta.y < 0) this.props.onSwipedUp && this.props.onSwipedUp(e, this.state.originalY, current.y) | ||
} | ||
if (delta.y > 0) this.props.onSwipedDown && this.props.onSwipedDown(e, this.state.originalY, current.y) | ||
if (delta.y < 0) this.props.onSwipedUp && this.props.onSwipedUp(e, this.state.originalY, current.y) | ||
} | ||
@@ -57,9 +51,2 @@ | ||
getScreenOffset () { | ||
return { | ||
x: this.props.screenXOffset || 0, | ||
y: this.props.screenYOffset || 0 | ||
} | ||
} | ||
getCurrentPosition (touch) { | ||
@@ -88,4 +75,2 @@ return { | ||
delete props.children | ||
delete props.screenXOffset | ||
delete props.screenYOffset | ||
delete props.onSwiping | ||
@@ -120,4 +105,2 @@ delete props.onSwiped | ||
children: React.PropTypes.element.isRequired, | ||
screenXOffset: React.PropTypes.number, | ||
screenYOffset: React.PropTypes.number, | ||
onSwiping: React.PropTypes.func, | ||
@@ -124,0 +107,0 @@ onSwiped: React.PropTypes.func, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16802
325