fix: fixed infinite loop bug when scroll to bottom

This commit is contained in:
XPoet 2020-10-26 10:42:33 +08:00
parent b101f7e67a
commit e10ed01eb1
1 changed files with 2 additions and 4 deletions

View File

@ -23,10 +23,10 @@ window.addEventListener('DOMContentLoaded', () => {
back2Bottom() {
let scrollHeight = document.body.scrollHeight || document.documentElement.scrollHeight;
const scrollBottomTimer = setInterval(function () {
let scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
const scrollBottomTimer = setInterval(function () {
if (!scrollTop) scrollTop = 10;
scrollTop = scrollTop + scrollTop / 2;
scrollTop = Math.floor(scrollTop + scrollTop / 2);
window.scrollTo(0, scrollTop);
if (scrollTop >= scrollHeight) {
clearInterval(scrollBottomTimer);
@ -54,5 +54,3 @@ window.addEventListener('DOMContentLoaded', () => {
ILS.utils.initBack2TopButton();
ILS.utils.initBack2BottomButton();
});