From a013d647e02ab1c244cbecab7817c00bddbb5583 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com> Date: Fri, 2 Oct 2020 11:13:55 -0400 Subject: [PATCH] Adjust PostStreamScrubber height after scroll (#2333) --- js/src/forum/components/PostStream.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/js/src/forum/components/PostStream.js b/js/src/forum/components/PostStream.js index a80f75bec..21d6ee240 100644 --- a/js/src/forum/components/PostStream.js +++ b/js/src/forum/components/PostStream.js @@ -345,17 +345,23 @@ export default class PostStream extends Component { } } - // Even before scrolling, we want to provide location information - // to the scrubber as soon as possible. This way, we avoid an unnecessary - // and confusing animation. - this.updateScrubber(); - // We manually set the index because we want to display the index of the - // exact post we've scrolled to, not just that of the first post on the page. - this.stream.index = index; + const updateScrubberHeight = () => { + // We manually set the index because we want to display the index of the + // exact post we've scrolled to, not just that of the first post within viewport. + this.updateScrubber(); + this.stream.index = index; + }; + + // If we don't update this before the scroll, the scrubber will start + // at the top, and animate down, which can be confusing + updateScrubberHeight(); this.stream.forceUpdateScrubber = true; return Promise.all([$container.promise(), this.stream.loadPromise]).then(() => { m.redraw.sync(); + // We want to adjust this again after posts have been loaded in so that + // the height of the scrubber is accurate. + updateScrubberHeight(); // After post data has been loaded in, we will attempt to scroll back // to the top of the requested post (or to the top of the page if the