Spike on scroll during prepend

Co-authored-by: Stamates <stamates@hotmail.com>
pull/769/head
jimmay5469 6 years ago
parent f6318e9a56
commit cfdca2a5c9
  1. 18
      apps/block_scout_web/assets/js/pages/block.js

@ -58,6 +58,24 @@ if ($blockListPage.length) {
if (state.channelDisconnected) $channelDisconnected.show()
if (oldState.newBlock !== state.newBlock) {
const fromBottom = document.body.scrollHeight - window.scrollY
let clingBottomAnimationFrame
let expectedScrollPosition = window.scrollY
function clingBottom () {
if (expectedScrollPosition !== window.scrollY) return stopCling()
expectedScrollPosition = document.body.scrollHeight - fromBottom
$(window).scrollTop(expectedScrollPosition)
clingBottomAnimationFrame = requestAnimationFrame(clingBottom)
}
function stopCling () {
cancelAnimationFrame(clingBottomAnimationFrame)
$blocksList.off('animationend animationcancel', stopCling)
}
if (window.scrollY > $blocksList.offset().top) {
clingBottomAnimationFrame = requestAnimationFrame(clingBottom)
$blocksList.on('animationend animationcancel', stopCling)
}
$blocksList.prepend(state.newBlock)
updateAllAges()
}

Loading…
Cancel
Save