1
0
mirror of https://github.com/mastodon/mastodon synced 2024-12-01 08:18:22 +09:00

fix(status_list): Update scroll position after toots are appended (#4277)

This commit is contained in:
Sorin Davidoi 2017-07-19 22:38:26 +02:00 committed by Eugen Rochko
parent dcb9497148
commit e01966f7b8

View File

@ -57,14 +57,15 @@ export default class StatusList extends ImmutablePureComponent {
componentDidUpdate (prevProps) { componentDidUpdate (prevProps) {
// Reset the scroll position when a new toot comes in in order not to // Reset the scroll position when a new toot comes in in order not to
// jerk the scrollbar around if you're already scrolled down the page. // jerk the scrollbar around if you're already scrolled down the page.
if (prevProps.statusIds.size < this.props.statusIds.size && if (prevProps.statusIds.size < this.props.statusIds.size && this._oldScrollPosition && this.node.scrollTop > 0) {
prevProps.statusIds.first() !== this.props.statusIds.first() && if (prevProps.statusIds.first() !== this.props.statusIds.first()) {
this._oldScrollPosition &&
this.node.scrollTop > 0) {
let newScrollTop = this.node.scrollHeight - this._oldScrollPosition; let newScrollTop = this.node.scrollHeight - this._oldScrollPosition;
if (this.node.scrollTop !== newScrollTop) { if (this.node.scrollTop !== newScrollTop) {
this.node.scrollTop = newScrollTop; this.node.scrollTop = newScrollTop;
} }
} else {
this._oldScrollPosition = this.node.scrollHeight - this.node.scrollTop;
}
} }
} }