|
|
@ -17,7 +17,7 @@ export default class ScrollableList extends PureComponent { |
|
|
|
|
|
|
|
|
|
|
|
static propTypes = { |
|
|
|
static propTypes = { |
|
|
|
scrollKey: PropTypes.string.isRequired, |
|
|
|
scrollKey: PropTypes.string.isRequired, |
|
|
|
onScrollToBottom: PropTypes.func, |
|
|
|
onLoadMore: PropTypes.func.isRequired, |
|
|
|
onScrollToTop: PropTypes.func, |
|
|
|
onScrollToTop: PropTypes.func, |
|
|
|
onScroll: PropTypes.func, |
|
|
|
onScroll: PropTypes.func, |
|
|
|
trackScroll: PropTypes.bool, |
|
|
|
trackScroll: PropTypes.bool, |
|
|
@ -44,9 +44,11 @@ export default class ScrollableList extends PureComponent { |
|
|
|
const { scrollTop, scrollHeight, clientHeight } = this.node; |
|
|
|
const { scrollTop, scrollHeight, clientHeight } = this.node; |
|
|
|
const offset = scrollHeight - scrollTop - clientHeight; |
|
|
|
const offset = scrollHeight - scrollTop - clientHeight; |
|
|
|
|
|
|
|
|
|
|
|
if (400 > offset && this.props.onScrollToBottom && !this.props.isLoading) { |
|
|
|
if (400 > offset && this.props.onLoadMore && !this.props.isLoading) { |
|
|
|
this.props.onScrollToBottom(); |
|
|
|
this.props.onLoadMore(); |
|
|
|
} else if (scrollTop < 100 && this.props.onScrollToTop) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (scrollTop < 100 && this.props.onScrollToTop) { |
|
|
|
this.props.onScrollToTop(); |
|
|
|
this.props.onScrollToTop(); |
|
|
|
} else if (this.props.onScroll) { |
|
|
|
} else if (this.props.onScroll) { |
|
|
|
this.props.onScroll(); |
|
|
|
this.props.onScroll(); |
|
|
@ -144,7 +146,7 @@ export default class ScrollableList extends PureComponent { |
|
|
|
|
|
|
|
|
|
|
|
handleLoadMore = (e) => { |
|
|
|
handleLoadMore = (e) => { |
|
|
|
e.preventDefault(); |
|
|
|
e.preventDefault(); |
|
|
|
this.props.onScrollToBottom(); |
|
|
|
this.props.onLoadMore(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
render () { |
|
|
|
render () { |
|
|
|