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() { componentDidMount() {
this.mounted = true;
this.scrollTop = -1; this.scrollTop = -1;
} }
@ -113,6 +114,7 @@ export default class MessageBox extends PureComponent {
}, 100); }, 100);
handleScroll = ({ scrollTop, clientHeight, scrollHeight }) => { handleScroll = ({ scrollTop, clientHeight, scrollHeight }) => {
if (this.mounted) {
if (this.props.hasMoreMessages && if (this.props.hasMoreMessages &&
scrollTop <= fetchThreshold && scrollTop <= fetchThreshold &&
scrollTop < this.prevScrollTop && scrollTop < this.prevScrollTop &&
@ -126,6 +128,7 @@ export default class MessageBox extends PureComponent {
this.bottom = scrollTop + clientHeight >= scrollHeight - 10; this.bottom = scrollTop + clientHeight >= scrollHeight - 10;
this.prevScrollTop = scrollTop; this.prevScrollTop = scrollTop;
}
}; };
handleMouseDown = () => { handleMouseDown = () => {