From 72ea3e5413ce5eb20881b614a77522adbe36220f Mon Sep 17 00:00:00 2001 From: Xianglin He Date: Fri, 1 Mar 2019 12:03:36 +0800 Subject: [PATCH 1/2] added sensitivityY support to distinct dx and dy of gestureState. --- dist/index.js | 8 +++++--- index.d.ts | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index d4a976c5..34226f7d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -124,7 +124,8 @@ var Swipeout = (0, _createReactClass2.default)({ right: _propTypes2.default.array, scroll: _propTypes2.default.func, style: (_reactNative.ViewPropTypes || _reactNative.View.propTypes).style, - sensitivity: _propTypes2.default.number, + sensitivityX: _propTypes2.default.number, + sensitivityY: _propTypes2.default.number, buttonWidth: _propTypes2.default.number, disabled: _propTypes2.default.bool }, @@ -134,7 +135,8 @@ var Swipeout = (0, _createReactClass2.default)({ disabled: false, rowID: -1, sectionID: -1, - sensitivity: 50 + sensitivityX: 50, + sensitivityY: 50 }; }, @@ -165,7 +167,7 @@ var Swipeout = (0, _createReactClass2.default)({ return _this.state.openedLeft || _this.state.openedRight; }, onMoveShouldSetPanResponderCapture: function onMoveShouldSetPanResponderCapture(event, gestureState) { - return Math.abs(gestureState.dx) > _this.props.sensitivity && Math.abs(gestureState.dy) <= _this.props.sensitivity; + return Math.abs(gestureState.dx) > _this.props.sensitivityX && Math.abs(gestureState.dy) <= _this.props.sensitivityY; }, onPanResponderGrant: this._handlePanResponderGrant, onPanResponderMove: this._handlePanResponderMove, diff --git a/index.d.ts b/index.d.ts index e8364b7b..9a35038b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -23,7 +23,8 @@ declare module 'react-native-swipeout' { right?: SwipeoutButtonProperties[]; scroll?(scrollEnabled: boolean): void; style?: Object; - sensitivity?: number; + sensitivityX?: number; + sensitivityY?: number; buttonWidth?: number; rowId?: number; sectionId?: number; From 4bd2fd822525a8c0562c6d7e41e81a6726bbaa75 Mon Sep 17 00:00:00 2001 From: Xianglin He Date: Fri, 1 Mar 2019 14:00:06 +0800 Subject: [PATCH 2/2] disabled onOpen, onClose callback when gesture start. --- dist/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/index.js b/dist/index.js index 34226f7d..a5f06fb7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -192,11 +192,11 @@ var Swipeout = (0, _createReactClass2.default)({ var _this2 = this; if (this.props.disabled) return; - if (!this.state.openedLeft && !this.state.openedRight) { - this._callOnOpen(); - } else { - this._callOnClose(); - } + // if (!this.state.openedLeft && !this.state.openedRight) { + // this._callOnOpen(); + // } else { + // this._callOnClose(); + // } this.refs.swipeoutContent.measure(function (ox, oy, width, height) { var buttonWidth = _this2.props.buttonWidth || width / 5; _this2.setState({