Skip to content

Commit 3e89fd6

Browse files
committed
fix bug #15
1 parent c2e4793 commit 3e89fd6

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

SmartRefreshControl.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
UIManager,
99
NativeModules,
1010
Platform,
11+
PanResponder,
1112
} from 'react-native';
1213
import ClassicsHeader from "./ClassicsHeader";
1314
import {ViewPropTypes,PropTypes} from './Util'
@@ -43,6 +44,16 @@ class SmartRefreshControl extends Component {
4344

4445
return findNodeHandle(this.refs.refreshLayout);
4546
}
47+
componentWillMount() {
48+
this._panResponder = PanResponder.create({
49+
onMoveShouldSetPanResponderCapture: (evt, gestureState) => {
50+
if(Math.abs(gestureState.dx)>1 || Math.abs(gestureState.dy) >1){
51+
return true
52+
}
53+
return false;
54+
}
55+
});
56+
}
4657
renderHeader=()=>{
4758
const {HeaderComponent}=this.props;
4859
if(HeaderComponent){
@@ -61,13 +72,14 @@ class SmartRefreshControl extends Component {
6172
}
6273
render() {
6374
const nativeProps ={...this.props,...{
64-
onSmartRefresh:this._onSmartRefresh,
65-
}}
75+
onSmartRefresh:this._onSmartRefresh,
76+
}}
6677
return (
6778
<SmartRefreshLayout
6879
ref="refreshLayout"
6980
{...nativeProps}
70-
onMoveShouldSetResponderCapture={()=>true}//拦截子组件的触摸移动事件
81+
{...this._panResponder.panHandlers}
82+
//onMoveShouldSetResponderCapture={()=>true}//拦截子组件的触摸移动事件
7183
>
7284
{this.renderHeader()}
7385
{React.cloneElement(

0 commit comments

Comments
 (0)