Prevent autoscroll flag being cleared on mount by initial scroll tick

This commit is contained in:
Ken-Håvard Lieng 2017-05-08 23:22:53 +02:00
parent 909c31dff8
commit 4dd9671e87
2 changed files with 33 additions and 30 deletions

File diff suppressed because one or more lines are too long

View File

@ -13,6 +13,7 @@ export default class MessageBox extends PureComponent {
}
componentDidMount() {
this.mounted = true;
this.scrollTop = -1;
}
@ -113,19 +114,21 @@ export default class MessageBox extends PureComponent {
}, 100);
handleScroll = ({ scrollTop, clientHeight, scrollHeight }) => {
if (this.props.hasMoreMessages &&
scrollTop <= fetchThreshold &&
scrollTop < this.prevScrollTop &&
!this.loading) {
if (this.mouseDown) {
this.shouldFetch = true;
} else {
this.fetchMore();
if (this.mounted) {
if (this.props.hasMoreMessages &&
scrollTop <= fetchThreshold &&
scrollTop < this.prevScrollTop &&
!this.loading) {
if (this.mouseDown) {
this.shouldFetch = true;
} else {
this.fetchMore();
}
}
}
this.bottom = scrollTop + clientHeight >= scrollHeight - 10;
this.prevScrollTop = scrollTop;
this.bottom = scrollTop + clientHeight >= scrollHeight - 10;
this.prevScrollTop = scrollTop;
}
};
handleMouseDown = () => {