]> cat aescling's git repositories - mastodon.git/commitdiff
fix(status_list): Update scroll position after toots are appended (#4277)
authorSorin Davidoi <sorin.davidoi@gmail.com>
Wed, 19 Jul 2017 20:38:26 +0000 (22:38 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Wed, 19 Jul 2017 20:38:26 +0000 (22:38 +0200)
app/javascript/mastodon/components/status_list.js

index a8ea1ec5b1aef41a0b0821339d43c6da591a427a..98f0de0a850c8642e814f617a976469d3c752317 100644 (file)
@@ -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;
       }
     }
   }