keep message view in the same scroll position on vertical resize

This commit is contained in:
or-else
2018-11-17 21:34:13 +03:00
parent 9324faa32f
commit 198bd9a64c
2 changed files with 13 additions and 2 deletions
+4
View File
@@ -156,6 +156,10 @@ class MessagesView extends React.Component {
// The user switched to the new topic before the timer for
// the previous topic has triggered, kill it.
this.props.readTimerHandler(null);
} else if (props.viewportHeight < this.props.viewportHeight) {
console.log("Viewport shrunk vertically by", -props.viewportHeight + this.props.viewportHeight);
let scrollPosition = Math.max(0, this.state.scrollPosition - props.viewportHeight + this.props.viewportHeight);
this.setState({scrollPosition: scrollPosition});
}
this.setState({