Prevent autoscroll flag being cleared on mount by initial scroll tick
This commit is contained in:
parent
909c31dff8
commit
4dd9671e87
File diff suppressed because one or more lines are too long
@ -13,6 +13,7 @@ export default class MessageBox extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
this.mounted = true;
|
||||||
this.scrollTop = -1;
|
this.scrollTop = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,19 +114,21 @@ export default class MessageBox extends PureComponent {
|
|||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
handleScroll = ({ scrollTop, clientHeight, scrollHeight }) => {
|
handleScroll = ({ scrollTop, clientHeight, scrollHeight }) => {
|
||||||
if (this.props.hasMoreMessages &&
|
if (this.mounted) {
|
||||||
scrollTop <= fetchThreshold &&
|
if (this.props.hasMoreMessages &&
|
||||||
scrollTop < this.prevScrollTop &&
|
scrollTop <= fetchThreshold &&
|
||||||
!this.loading) {
|
scrollTop < this.prevScrollTop &&
|
||||||
if (this.mouseDown) {
|
!this.loading) {
|
||||||
this.shouldFetch = true;
|
if (this.mouseDown) {
|
||||||
} else {
|
this.shouldFetch = true;
|
||||||
this.fetchMore();
|
} else {
|
||||||
|
this.fetchMore();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
this.bottom = scrollTop + clientHeight >= scrollHeight - 10;
|
this.bottom = scrollTop + clientHeight >= scrollHeight - 10;
|
||||||
this.prevScrollTop = scrollTop;
|
this.prevScrollTop = scrollTop;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleMouseDown = () => {
|
handleMouseDown = () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user