react-with-gesture
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -57,13 +57,23 @@ import React from 'react'; | ||
}, _this.handleTouchStart = function (e) { | ||
return _this.handleMouseDown(e.touches[0]); | ||
return e.preventDefault() || _this.handleMouseDown(e.touches[0]); | ||
}, _this.handleTouchMove = function (e) { | ||
return e.preventDefault() || _this.handleMouseMove(e.touches[0]); | ||
}, _this.handleMouseUp = function () { | ||
return _this.setState({ | ||
window.removeEventListener('touchmove', _this.handleTouchMove); | ||
window.removeEventListener('touchend', _this.handleMouseUp); | ||
window.removeEventListener('mousemove', _this.handleMouseMove); | ||
window.removeEventListener('mouseup', _this.handleMouseUp); | ||
var newProps = { | ||
down: false | ||
}); | ||
}; | ||
_this.setState(_this.props.onUp ? _this.props.onMouseUp(newProps) : newProps); | ||
}, _this.handleMouseDown = function (_ref) { | ||
var pageX = _ref.pageX, | ||
pageY = _ref.pageY; | ||
return _this.setState({ | ||
window.addEventListener('touchmove', _this.handleTouchMove); | ||
window.addEventListener('touchend', _this.handleMouseUp); | ||
window.addEventListener('mousemove', _this.handleMouseMove); | ||
window.addEventListener('mouseup', _this.handleMouseUp); | ||
var newProps = { | ||
x: pageX, | ||
@@ -76,7 +86,9 @@ y: pageX, | ||
down: true | ||
}); | ||
}; | ||
_this.setState(_this.props.onDown ? _this.props.onDown(newProps) : newProps); | ||
}, _this.handleMouseMove = function (_ref2) { | ||
var pageX = _ref2.pageX, | ||
pageY = _ref2.pageY; | ||
return _this.state.down && _this.setState({ | ||
var newProps = { | ||
x: pageX, | ||
@@ -86,3 +98,5 @@ y: pageX, | ||
yDelta: pageY - _this.state.yInitial | ||
}); | ||
}; | ||
_this.setState(_this.props.onMove ? _this.props.onMove(newProps) : newProps); | ||
}, _temp) || _assertThisInitialized(_this); | ||
@@ -93,16 +107,2 @@ } | ||
_proto.componentDidMount = function componentDidMount() { | ||
window.addEventListener('touchmove', this.handleTouchMove); | ||
window.addEventListener('touchend', this.handleMouseUp); | ||
window.addEventListener('mousemove', this.handleMouseMove); | ||
window.addEventListener('mouseup', this.handleMouseUp); | ||
}; | ||
_proto.componentWillUnmount = function componentWillUnmount() { | ||
window.removeEventListener('touchmove', this.handleTouchMove); | ||
window.removeEventListener('touchend', this.handleMouseUp); | ||
window.removeEventListener('mousemove', this.handleMouseMove); | ||
window.removeEventListener('mouseup', this.handleMouseUp); | ||
}; | ||
_proto.render = function render() { | ||
@@ -109,0 +109,0 @@ return React.createElement("div", { |
@@ -63,13 +63,23 @@ 'use strict'; | ||
}, _this.handleTouchStart = function (e) { | ||
return _this.handleMouseDown(e.touches[0]); | ||
return e.preventDefault() || _this.handleMouseDown(e.touches[0]); | ||
}, _this.handleTouchMove = function (e) { | ||
return e.preventDefault() || _this.handleMouseMove(e.touches[0]); | ||
}, _this.handleMouseUp = function () { | ||
return _this.setState({ | ||
window.removeEventListener('touchmove', _this.handleTouchMove); | ||
window.removeEventListener('touchend', _this.handleMouseUp); | ||
window.removeEventListener('mousemove', _this.handleMouseMove); | ||
window.removeEventListener('mouseup', _this.handleMouseUp); | ||
var newProps = { | ||
down: false | ||
}); | ||
}; | ||
_this.setState(_this.props.onUp ? _this.props.onMouseUp(newProps) : newProps); | ||
}, _this.handleMouseDown = function (_ref) { | ||
var pageX = _ref.pageX, | ||
pageY = _ref.pageY; | ||
return _this.setState({ | ||
window.addEventListener('touchmove', _this.handleTouchMove); | ||
window.addEventListener('touchend', _this.handleMouseUp); | ||
window.addEventListener('mousemove', _this.handleMouseMove); | ||
window.addEventListener('mouseup', _this.handleMouseUp); | ||
var newProps = { | ||
x: pageX, | ||
@@ -82,7 +92,9 @@ y: pageX, | ||
down: true | ||
}); | ||
}; | ||
_this.setState(_this.props.onDown ? _this.props.onDown(newProps) : newProps); | ||
}, _this.handleMouseMove = function (_ref2) { | ||
var pageX = _ref2.pageX, | ||
pageY = _ref2.pageY; | ||
return _this.state.down && _this.setState({ | ||
var newProps = { | ||
x: pageX, | ||
@@ -92,3 +104,5 @@ y: pageX, | ||
yDelta: pageY - _this.state.yInitial | ||
}); | ||
}; | ||
_this.setState(_this.props.onMove ? _this.props.onMove(newProps) : newProps); | ||
}, _temp) || _assertThisInitialized(_this); | ||
@@ -99,16 +113,2 @@ } | ||
_proto.componentDidMount = function componentDidMount() { | ||
window.addEventListener('touchmove', this.handleTouchMove); | ||
window.addEventListener('touchend', this.handleMouseUp); | ||
window.addEventListener('mousemove', this.handleMouseMove); | ||
window.addEventListener('mouseup', this.handleMouseUp); | ||
}; | ||
_proto.componentWillUnmount = function componentWillUnmount() { | ||
window.removeEventListener('touchmove', this.handleTouchMove); | ||
window.removeEventListener('touchend', this.handleMouseUp); | ||
window.removeEventListener('mousemove', this.handleMouseMove); | ||
window.removeEventListener('mouseup', this.handleMouseUp); | ||
}; | ||
_proto.render = function render() { | ||
@@ -115,0 +115,0 @@ return React.createElement("div", { |
{ | ||
"name": "react-with-gesture", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "hoc for receiving gestures", | ||
@@ -5,0 +5,0 @@ "main": "dist/react-with-gesture", |
@@ -7,3 +7,15 @@ import React from 'react' | ||
componentDidMount() { | ||
handleTouchStart = e => e.preventDefault() || this.handleMouseDown(e.touches[0]) | ||
handleTouchMove = e => e.preventDefault() || this.handleMouseMove(e.touches[0]) | ||
handleMouseUp = () => { | ||
window.removeEventListener('touchmove', this.handleTouchMove) | ||
window.removeEventListener('touchend', this.handleMouseUp) | ||
window.removeEventListener('mousemove', this.handleMouseMove) | ||
window.removeEventListener('mouseup', this.handleMouseUp) | ||
const newProps = { down: false } | ||
this.setState(this.props.onUp ? this.props.onMouseUp(newProps) : newProps) | ||
} | ||
handleMouseDown = ({ pageX, pageY }) => { | ||
window.addEventListener('touchmove', this.handleTouchMove) | ||
@@ -13,20 +25,11 @@ window.addEventListener('touchend', this.handleMouseUp) | ||
window.addEventListener('mouseup', this.handleMouseUp) | ||
const newProps = { x: pageX, y: pageX, xDelta: 0, yDelta: 0, xInitial: pageX, yInitial: pageY, down: true } | ||
this.setState(this.props.onDown ? this.props.onDown(newProps) : newProps) | ||
} | ||
componentWillUnmount() { | ||
window.removeEventListener('touchmove', this.handleTouchMove) | ||
window.removeEventListener('touchend', this.handleMouseUp) | ||
window.removeEventListener('mousemove', this.handleMouseMove) | ||
window.removeEventListener('mouseup', this.handleMouseUp) | ||
handleMouseMove = ({ pageX, pageY }) => { | ||
const newProps = { x: pageX, y: pageX, xDelta: pageX - this.state.xInitial, yDelta: pageY - this.state.yInitial } | ||
this.setState(this.props.onMove ? this.props.onMove(newProps) : newProps) | ||
} | ||
handleTouchStart = e => this.handleMouseDown(e.touches[0]) | ||
handleTouchMove = e => e.preventDefault() || this.handleMouseMove(e.touches[0]) | ||
handleMouseUp = () => this.setState({ down: false }) | ||
handleMouseDown = ({ pageX, pageY }) => | ||
this.setState({ x: pageX, y: pageX, xDelta: 0, yDelta: 0, xInitial: pageX, yInitial: pageY, down: true }) | ||
handleMouseMove = ({ pageX, pageY }) => | ||
this.state.down && | ||
this.setState({ x: pageX, y: pageX, xDelta: pageX - this.state.xInitial, yDelta: pageY - this.state.yInitial }) | ||
render() { | ||
@@ -33,0 +36,0 @@ return ( |
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
80800