Skip to content

Commit 800e907

Browse files
committed
添加 默认参数 downEnough
1 parent d3b2d03 commit 800e907

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

src/ReactPullLoad.jsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ export default class ReactPullLoad extends Component {
4949

5050
componentDidMount() {
5151
this.defaultConfig = {
52-
container: document.body,//findDOMNode(this),
53-
offsetScrollTop: 2,
54-
offsetY: 75,
55-
distanceBottom: 100,
52+
container: document.body,//findDOMNode(this),
53+
offsetScrollTop: this.props.offsetScrollTop || ReactPullLoad.offsetScrollTop,
54+
downEnough: this.props.downEnough || ReactPullLoad.downEnough,
55+
distanceBottom: this.props.distanceBottom || ReactPullLoad.distanceBottom,
5656
onPullDownMove: this.onPullDownMove.bind(this),
5757
onPullDownRefresh: this.onPullDownRefresh.bind(this),
5858
clearPullDownMove: this.clearPullDownMove.bind(this),
@@ -91,7 +91,7 @@ export default class ReactPullLoad extends Component {
9191
diff = 0;
9292
}
9393
diff = this.easing(diff);
94-
if (diff > 100) {
94+
if (diff > this.defaultConfig.downEnough) {
9595
loaderState = STATS.enough
9696
} else {
9797
loaderState = STATS.pulling
@@ -273,6 +273,11 @@ export default class ReactPullLoad extends Component {
273273
ReactPullLoad.propTypes = {
274274
onRefresh: PropTypes.func.isRequired,
275275
onLoadMore: PropTypes.func,
276-
hasMore: PropTypes.bool
277-
// initializing: PropTypes.string
278-
}
276+
hasMore: PropTypes.bool,
277+
offsetScrollTop: PropTypes.number,
278+
downEnough: PropTypes.number,
279+
distanceBottom: PropTypes.number
280+
}
281+
ReactPullLoad.offsetScrollTop = 2 //与顶部的距离
282+
ReactPullLoad.downEnough = 100 //下拉满足刷新的距离
283+
ReactPullLoad.distanceBottom = 100 //距离底部距离触发加载更多

0 commit comments

Comments
 (0)