react-native-pullview
Advanced tools
+24
-12
@@ -41,3 +41,5 @@ 'use strict'; | ||
| Demo: | ||
| <ScrollView onPulling={} onPullOk={} onPullRelease={} isPullEnd={true} | ||
| import PullView from 'react-native-pullview'; | ||
| <PullView onPulling={} onPullOk={} onPullRelease={} isPullEnd={true} | ||
| topIndicatorRender={({pulling, pullok, pullrelease}) => {}} topIndicatorHeight={60} | ||
@@ -55,3 +57,3 @@ > | ||
| } | ||
| <ScrollView onPullRelease={this.props.onRefresh} topIndicatorRender={this.topIndicatorRender} topIndicatorHeight={60} ></ScrollView> | ||
| <PullView onPullRelease={this.props.onRefresh} topIndicatorRender={this.topIndicatorRender} topIndicatorHeight={60} ></PullView> | ||
@@ -71,3 +73,3 @@ Demo3: | ||
| } | ||
| <ScrollView refreshControl={} onRefresh={this.onRefresh} refreshing={this.state.refreshing}></ScrollView> | ||
| <PullView refreshControl={} onRefresh={this.onRefresh} refreshing={this.state.refreshing}></PullView> | ||
| */ | ||
@@ -91,3 +93,4 @@ | ||
| this.onLayout = this.onLayout.bind(this); | ||
| this.resetDefaultXY = this.resetDefaultXY.bind(this); | ||
| this.isPullState = this.isPullState.bind(this); | ||
| this.resetDefaultXYHandler = this.resetDefaultXYHandler.bind(this); | ||
| this.panResponder = PanResponder.create({ | ||
@@ -116,3 +119,7 @@ onStartShouldSetPanResponder: this.onShouldSetPanResponder.bind(this), | ||
| if (isUpGesture(gesture.dx, gesture.dy)) { //向上滑动 | ||
| this.scroll.scrollTo({x:0, y: gesture.dy * -1}); | ||
| if(this.isPullState()) { | ||
| this.resetDefaultXYHandler() | ||
| } else { | ||
| this.scroll.scrollTo({x:0, y: gesture.dy * -1}); | ||
| } | ||
| return; | ||
@@ -123,3 +130,3 @@ } else if (isDownGesture(gesture.dx, gesture.dy)) { //下拉 | ||
| if (!this.state.pulling) { | ||
| this.props.onPulling && this.props.onPulling(this.resetDefaultXY); | ||
| this.props.onPulling && this.props.onPulling(this.resetDefaultXYHandler); | ||
| } | ||
@@ -129,3 +136,3 @@ this.setState({pulling: true, pullok: false, pullrelease: false}); //正在下拉 | ||
| if (!this.state.pullok) { | ||
| this.props.onPullOk && this.props.onPullOk(this.resetDefaultXY); | ||
| this.props.onPullOk && this.props.onPullOk(this.resetDefaultXYHandler); | ||
| } | ||
@@ -141,3 +148,3 @@ this.setState({pulling: false, pullok: true, pullrelease: false}); //下拉到位 | ||
| if (!this.state.pullrelease) { | ||
| this.props.onPullRelease && this.props.onPullRelease(this.resetDefaultXY); | ||
| this.props.onPullRelease && this.props.onPullRelease(this.resetDefaultXYHandler); | ||
| } | ||
@@ -154,5 +161,5 @@ this.setState({pulling: false, pullok: false, pullrelease: true}); //完成下拉,已松开 | ||
| onScroll(e) { | ||
| if (e.nativeEvent.contentOffset.y == 0) { | ||
| if (e.nativeEvent.contentOffset.y <= 0) { | ||
| this.setState({scrollEnabled: this.defaultScrollEnabled}); | ||
| } else { | ||
| } else if(!this.isPullState()) { | ||
| this.setState({scrollEnabled: true}); | ||
@@ -162,3 +169,8 @@ } | ||
| resetDefaultXY() { | ||
| isPullState() { | ||
| return this.state.pulling || this.state.pullok || this.state.pullrelease; | ||
| } | ||
| resetDefaultXYHandler() { | ||
| this.setState({pulling: false, pullok: false, pullrelease: false}); | ||
| this.state.pullPan.setValue(this.defaultXY); | ||
@@ -169,3 +181,3 @@ } | ||
| if (nextProps.isPullEnd && this.state.pullrelease) { | ||
| this.resetDefaultXY(); | ||
| this.resetDefaultXYHandler(); | ||
| } | ||
@@ -172,0 +184,0 @@ } |
+1
-1
| { | ||
| "name": "react-native-pullview", | ||
| "version": "1.0.5", | ||
| "version": "1.0.6", | ||
| "description": "PullView component in React Native both for Android and iOS, pull to refresh", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
12696
3.96%203
5.18%