mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Defering calculations for determining if user scrolled to bottom or not. slight delay improves the accuracy in responsive view (#5244)
This commit is contained in:
@@ -120,17 +120,10 @@ export default class PostList extends React.Component {
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.wasAtBottom = this.isAtBottom();
|
||||
if (!this.jumpToPostNode && childNodes.length > 0) {
|
||||
this.jumpToPostNode = childNodes[childNodes.length - 1];
|
||||
}
|
||||
|
||||
// --- --------
|
||||
|
||||
this.props.postListScrolled(this.isAtBottom());
|
||||
this.prevScrollHeight = this.refs.postlist.scrollHeight;
|
||||
this.prevOffsetTop = this.jumpToPostNode.offsetTop;
|
||||
|
||||
this.updateFloatingTimestamp();
|
||||
|
||||
if (!this.state.isScrolling) {
|
||||
@@ -139,6 +132,15 @@ export default class PostList extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
// Postpone all DOM related calculations to next frame.
|
||||
// scrollHeight etc might return wrong data at this point
|
||||
setTimeout(() => {
|
||||
this.wasAtBottom = this.isAtBottom();
|
||||
this.props.postListScrolled(this.isAtBottom());
|
||||
this.prevScrollHeight = this.refs.postlist.scrollHeight;
|
||||
this.prevOffsetTop = this.jumpToPostNode.offsetTop;
|
||||
}, 0);
|
||||
|
||||
this.scrollStopAction.fireAfter(Constants.SCROLL_DELAY);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user