隐藏JS
<!-- <script>
(function (w, d, i) {
function debounce(func, wait) {
let timeout;
return function () {
const context = this;
const args = arguments;
clearTimeout(timeout);
timeout = setTimeout(() => func.apply(context, args), wait);
};
}
var navbar = d.getElementById(i);
var prevScrollpos = w.pageYOffset;
w.onscroll = debounce(function () {
var currentScrollPos = w.pageYOffset;
if (Math.abs(currentScrollPos - prevScrollpos) > 5) { // 滚动阈值
if (prevScrollpos > currentScrollPos) {
navbar.style.top = '0';
} else {
navbar.style.top = '-100px';
}
prevScrollpos = currentScrollPos;
}
}, 25) // 防止快速滚动时频繁触发
})(window, document, 'header');
</script>
-->
master
parent
a14fd1f212
commit
c6b8de9435
Loading…
Reference in New Issue