diff --git a/lib/ControlledRefreshableListView.js b/lib/ControlledRefreshableListView.js index 8e2ef7c..e0dd06c 100644 --- a/lib/ControlledRefreshableListView.js +++ b/lib/ControlledRefreshableListView.js @@ -40,12 +40,12 @@ var ControlledRefreshableListView = React.createClass({ onResponderRelease: PropTypes.func, renderHeaderWrapper: (props, propName, componentName) => { if (props[propName]) { - return new Error("The 'renderHeaderWrapper' prop is no longer used"); + return new Error("The 'renderHeaderWrapper' prop is no longer used") } }, refreshingIndictatorComponent: (props, propName, componentName) => { if (props[propName]) { - return new Error("The 'refreshingIndictatorComponent' prop has been renamed to 'refreshingIndicatorComponent'"); + return new Error("The 'refreshingIndictatorComponent' prop has been renamed to 'refreshingIndicatorComponent'") } }, }, @@ -64,7 +64,6 @@ var ControlledRefreshableListView = React.createClass({ }, componentWillReceiveProps(nextProps) { if (!this.props.isRefreshing && nextProps.isRefreshing && this.isTouching) { - this.waitingForRelease = true this.setState({waitingForRelease: true}) } @@ -101,7 +100,7 @@ var ControlledRefreshableListView = React.createClass({ if (this.isTouching || (!this.isTouching && !this.props.ignoreInertialScroll)) { if (scrollY < -this.props.minPulldownDistance) { - if (!this.props.isRefreshing) { + if (!this.props.isRefreshing && !this.state.waitingForRelease) { if (this.props.onRefresh) { this.props.onRefresh() } @@ -139,7 +138,7 @@ var ControlledRefreshableListView = React.createClass({ this.refs[LISTVIEW_REF].setNativeProps(props) }, isWaitingForRelease() { - return this.waitingForRelease || this.props.waitingForRelease + return this.waitingForRelease || this.state.waitingForRelease }, isReleaseUpdate(oldProps, oldState, newProps, newState) { return ( @@ -153,7 +152,7 @@ var ControlledRefreshableListView = React.createClass({ isRefreshing, description: refreshDescription, prompt: refreshPrompt, - pulldownDistance: -(this.lastScrollY || 0) + pulldownDistance: -(this.lastScrollY || 0), } return createElementFrom(this.props.refreshingIndicatorComponent, refreshingIndicatorProps) }, @@ -181,32 +180,32 @@ var ControlledRefreshableListView = React.createClass({ var stylesheet = StyleSheet.create({ container: { - // flex: 1, + flex: 1, }, fillParent: { backgroundColor: 'transparent', position: 'absolute', - top: 0, - left: 0, - right: 0, - bottom: 0, - }, - // offsetParent: { - // position: 'relative', - // }, - // positionTopLeft: { - // position: 'absolute', - // top: 0, - // left: 0, - // }, - // fill: { - // flex: 1 - // }, - // center: { - // flex: 1, - // justifyContent: 'space-around', - // alignItems: 'center', - // }, + top: 0, + left: 0, + right: 0, + bottom: 0, + }, + offsetParent: { + position: 'relative', + }, + positionTopLeft: { + position: 'absolute', + top: 0, + left: 0, + }, + fill: { + flex: 1, + }, + center: { + flex: 1, + justifyContent: 'space-around', + alignItems: 'center', + }, }) ControlledRefreshableListView.DataSource = ListView.DataSource diff --git a/lib/RefreshingIndicator.js b/lib/RefreshingIndicator.js index c5d7d13..f224af3 100644 --- a/lib/RefreshingIndicator.js +++ b/lib/RefreshingIndicator.js @@ -14,6 +14,8 @@ var RefreshingIndicator = React.createClass({ activityIndicatorComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.element]), stylesheet: PropTypes.object, description: PropTypes.oneOfType([PropTypes.string, PropTypes.element]), + isRefreshing: PropTypes.bool.isRequired, + prompt: PropTypes.string, }, getDefaultProps() { return { @@ -23,9 +25,9 @@ var RefreshingIndicator = React.createClass({ renderDescription(styles) { return ( - {this.props.isRefreshing ? this.props.description : this.props.prompt} + {this.props.isRefreshing ? this.props.description : this.props.prompt} - ); + ) }, renderActivityIndicator(styles) { if (!this.props.isRefreshing) return null