From 96474e3a6f9af544b9ad87fe4b7211b274ad1027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=84=B6=E5=88=99?= Date: Tue, 5 Dec 2017 18:05:03 +0800 Subject: [PATCH] fix stopPropagation, close #11 --- examples/base.js | 4 ++-- package.json | 2 +- src/PullToRefresh.tsx | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/examples/base.js b/examples/base.js index 60669f8..d52499c 100644 --- a/examples/base.js +++ b/examples/base.js @@ -6,7 +6,7 @@ import ReactDOM from 'react-dom'; class App extends React.Component { state = { refreshing: false, - switchContainer: true, + switchContainer: false, }; componentDidMount() { // setTimeout(() => { this.setState({ refreshing: true }); }, 10); @@ -39,7 +39,7 @@ class App extends React.Component { indicator={{ deactivate: '下拉' }} > {[1, 2, 3, 4, 5, 6, 7].map(i => -
item {i}
)} +
alert(1)}>item {i}
)}
{ static defaultProps = { prefixCls: 'rmc-pull-to-refresh', @@ -106,7 +120,7 @@ export default class PullToRefresh extends React.Component { touchcancel: this.onTouchEnd.bind(this, ele), }; Object.keys(this._to).forEach(key => { - ele.addEventListener(key, this._to[key]); + ele.addEventListener(key, this._to[key], willPreventDefault); }); } @@ -124,6 +138,7 @@ export default class PullToRefresh extends React.Component { this._ScreenY = this._startScreenY = e.touches[0].screenY; // 一开始 refreshing 为 true 时 this._lastScreenY 有值 this._lastScreenY = this._lastScreenY || 0; + e.stopPropagation(); } isEdge = (ele: any, direction: string) => {