From 1360723c3fdb7882ddaaaaf044a299a7ceab5e61 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 6 Jul 2020 18:41:58 -0400 Subject: [PATCH] Separate updateScrubber into separate method from onscroll --- js/src/forum/components/PostStream.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/js/src/forum/components/PostStream.js b/js/src/forum/components/PostStream.js index 66a8d73ea..31c9ae892 100644 --- a/js/src/forum/components/PostStream.js +++ b/js/src/forum/components/PostStream.js @@ -136,7 +136,7 @@ export default class PostStream extends Component { * * @param {Integer} top */ - onscroll(top) { + onscroll(top = window.pageYOffset) { if (this.state.paused) return; const marginTop = this.getMarginTop(); const viewportHeight = $(window).height() - marginTop; @@ -164,6 +164,14 @@ export default class PostStream extends Component { clearTimeout(this.calculatePositionTimeout); this.calculatePositionTimeout = setTimeout(this.calculatePosition.bind(this), 100); + this.updateScrubber(top); + } + + updateScrubber(top = window.pageYOffset) { + const marginTop = this.getMarginTop(); + const viewportHeight = $(window).height() - marginTop; + const viewportTop = top + marginTop; + // Before looping through all of the posts, we reset the scrollbar // properties to a 'default' state. These values reflect what would be // seen if the browser were scrolled right up to the top of the page,