Hide header when clicking on a footnote.
This commit is contained in:
parent
71b8e3576c
commit
22067e5d47
1 changed files with 11 additions and 0 deletions
|
|
@ -27,9 +27,15 @@ const header = document.getElementById('header');
|
|||
const DWELL_TIME = 1500;
|
||||
let lastpos = window.scrollY;
|
||||
let hideTimeout: NodeJS.Timeout;
|
||||
let hideScroll = false;
|
||||
function onScroll() {
|
||||
const currentpos = window.scrollY;
|
||||
clearTimeout(hideTimeout);
|
||||
if (hideScroll) {
|
||||
header?.classList.add('-translate-y-full');
|
||||
hideScroll = false;
|
||||
return;
|
||||
}
|
||||
if (currentpos <= 100 || currentpos < lastpos) {
|
||||
header?.classList.remove('-translate-y-full');
|
||||
console.log("<", currentpos, lastpos);
|
||||
|
|
@ -43,6 +49,11 @@ function onScroll() {
|
|||
}
|
||||
lastpos = currentpos;
|
||||
}
|
||||
document.querySelectorAll('sup > a').forEach((el) => {
|
||||
el.addEventListener('click', () => {
|
||||
hideScroll = true;
|
||||
}, {passive: true});
|
||||
});
|
||||
header?.addEventListener('mouseenter', () => clearTimeout(hideTimeout));
|
||||
header?.addEventListener('focusin', () => clearTimeout(hideTimeout));
|
||||
window.addEventListener('scroll', onScroll, {passive: true});
|
||||
|
|
|
|||
Loading…
Reference in a new issue