From 7d06b6cb0510356e378d9a6d669dc1ceb1adf862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=A4=E9=9C=86?= Date: Mon, 4 Jun 2018 15:49:26 +0800 Subject: [PATCH 1/2] fix: https://github.com/ant-design/ant-design-mobile/issues/1954 As rc-gesture revert preventDefault in v0.0.19 for tabs+listview issue (https://github.com/ant-design/ant-design-mobile/issues/2589). Then, rc-gesture@v0.0.20 fixed this issue by exposing the `event` as a property of Gesture object, and the Gesture object will be passed as the first parameter when invoked panMove event callback. So, `rc-swipeout` invokes `event.preventDefault()` to prevent scroll event when pan moving. --- examples/simple.tsx | 15 ++++++++++++--- package.json | 2 +- src/Swipeout.tsx | 7 ++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/examples/simple.tsx b/examples/simple.tsx index df9e2bf..ba07ab5 100644 --- a/examples/simple.tsx +++ b/examples/simple.tsx @@ -54,12 +54,21 @@ const SwipeDemo = () => ( ReactDOM.render(
- +
-
- +
Test scroll
+ + + + + + + + + +
, document.getElementById('__react-content'), ); diff --git a/package.json b/package.json index 521a5c2..4c4bef7 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "dependencies": { "babel-runtime": "6.x", "classnames": "2.x", - "rc-gesture": "~0.0.18", + "rc-gesture": "~0.0.20", "react-native-swipeout": "^2.2.2" }, "devDependencies": { diff --git a/src/Swipeout.tsx b/src/Swipeout.tsx index 6851c46..a1e452b 100644 --- a/src/Swipeout.tsx +++ b/src/Swipeout.tsx @@ -100,11 +100,16 @@ export default class Swipeout extends React.Component { } } onPanMove = (e) => { - const { moveStatus } = e; + const { moveStatus, srcEvent } = e; const { x: deltaX } = moveStatus; if (!this.swiping) { return; } + + // fixed scroll when it's pan and moving. + if (srcEvent && srcEvent.preventDefault) { + srcEvent.preventDefault(); + } this._setStyle(deltaX); } From 17b218f88fe9c640f2106a8413514b764e33628a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=A4=E9=9C=86?= Date: Mon, 4 Jun 2018 22:19:47 +0800 Subject: [PATCH 2/2] change version to 2.0.6 --- HISTORY.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 98c2400..00141d2 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,11 @@ # History +# 2.0.6 + +- fix: https://github.com/ant-design/ant-design-mobile/issues/1954 As rc-gesture revert preventDefault in v0.0.19 for tabs+listview issue (https://github.com/ant-design/ant-design-mobile/issues/2589). +- Then, rc-gesture@v0.0.20 fixed this issue by exposing the `event` as a property of Gesture object, and the Gesture object will be passed as the first parameter when invoked panMove event callback. +- So, `rc-swipeout` invokes `event.preventDefault()` to prevent scroll event when pan moving. + # 2.0.0 - replace `hammer.js` width [rc-gesture](https://github.com/react-component/gesture) diff --git a/package.json b/package.json index 4c4bef7..833cbca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-swipeout", - "version": "2.0.5", + "version": "2.0.6", "description": "swipe out ui component for react(web and react-native)", "keywords": [ "react",