Use range for userIsScrolling in case scrollTop is still working

Co-authored-by: Stamates <stamates@hotmail.com>
pull/769/head
jimmay5469 6 years ago
parent 1e236ce2a3
commit 66eee235b4
  1. 10
      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)
})

Loading…
Cancel
Save