From 66eee235b40573ae1dcd799b8b636e059bcafff8 Mon Sep 17 00:00:00 2001 From: jimmay5469 Date: Thu, 20 Sep 2018 11:41:53 -0400 Subject: [PATCH] Use range for userIsScrolling in case scrollTop is still working Co-authored-by: Stamates --- apps/block_scout_web/assets/js/utils.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/block_scout_web/assets/js/utils.js b/apps/block_scout_web/assets/js/utils.js index d1212b2e22..faa5a34c73 100644 --- a/apps/block_scout_web/assets/js/utils.js +++ b/apps/block_scout_web/assets/js/utils.js @@ -46,17 +46,19 @@ export function prependWithClingBottom ($el, content) { } $el.on('animationstart', setIsAnimating) - let expectedScrollPosition = window.scrollY + let startingScrollPosition = window.scrollY + let endingScrollPosition = window.scrollY function userIsScrolling () { - return expectedScrollPosition !== window.scrollY + return window.scrollY < startingScrollPosition || endingScrollPosition < window.scrollY } const clingDistanceFromBottom = document.body.scrollHeight - window.scrollY let clingBottomLoop = window.requestAnimationFrame(function clingBottom () { if (userIsScrolling()) return stopClinging() - expectedScrollPosition = document.body.scrollHeight - clingDistanceFromBottom - $(window).scrollTop(expectedScrollPosition) + startingScrollPosition = window.scrollY + endingScrollPosition = document.body.scrollHeight - clingDistanceFromBottom + $(window).scrollTop(endingScrollPosition) clingBottomLoop = window.requestAnimationFrame(clingBottom) })