about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorSorin Davidoi <sorin.davidoi@gmail.com>2017-07-19 22:38:26 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-07-19 22:38:26 +0200
commite01966f7b8201b04314cb0e8de34c2c1259b5ca3 (patch)
treebf36b5b4643e51c19cf4d9246b2eb3206120ec08 /app
parentdcb94971484c46e470b89032f174267ace86be5c (diff)
fix(status_list): Update scroll position after toots are appended (#4277)
Diffstat (limited to 'app')
-rw-r--r--app/javascript/mastodon/components/status_list.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/app/javascript/mastodon/components/status_list.js b/app/javascript/mastodon/components/status_list.js
index a8ea1ec5b..98f0de0a8 100644
--- a/app/javascript/mastodon/components/status_list.js
+++ b/app/javascript/mastodon/components/status_list.js
@@ -57,13 +57,14 @@ export default class StatusList extends ImmutablePureComponent {
   componentDidUpdate (prevProps) {
     // 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.
-    if (prevProps.statusIds.size < this.props.statusIds.size &&
-        prevProps.statusIds.first() !== this.props.statusIds.first() &&
-        this._oldScrollPosition &&
-        this.node.scrollTop > 0) {
-      let newScrollTop = this.node.scrollHeight - this._oldScrollPosition;
-      if (this.node.scrollTop !== newScrollTop) {
-        this.node.scrollTop = newScrollTop;
+    if (prevProps.statusIds.size < this.props.statusIds.size && this._oldScrollPosition && this.node.scrollTop > 0) {
+      if (prevProps.statusIds.first() !== this.props.statusIds.first()) {
+        let newScrollTop = this.node.scrollHeight - this._oldScrollPosition;
+        if (this.node.scrollTop !== newScrollTop) {
+          this.node.scrollTop = newScrollTop;
+        }
+      } else {
+        this._oldScrollPosition = this.node.scrollHeight - this.node.scrollTop;
       }
     }
   }