This commit is contained in:
杜恒 2021-06-16 11:10:52 +08:00
parent 3553ffb80c
commit 9797185091
2 changed files with 8 additions and 5 deletions

View File

@ -536,11 +536,14 @@ document.addEventListener('DOMContentLoaded', () => {
}; };
let Y = window.pageYOffset; let Y = window.pageYOffset;
handleHeader(Y); handleHeader(Y);
let _debounce = null;
$(document).on('scroll', function () { $(document).on('scroll', function () {
clearTimeout(_debounce);
_debounce = setTimeout(() => {
const diffY = Y - window.pageYOffset; const diffY = Y - window.pageYOffset;
if (window.requestAnimationFrame) requestAnimationFrame(handleHeader.bind(null, diffY)); handleHeader(diffY);
else handleHeader(diffY);
Y = window.pageYOffset; Y = window.pageYOffset;
}, 15);
}); });
} }
}); });

File diff suppressed because one or more lines are too long