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) })