force open navbar when at top of the page

This commit is contained in:
reschan 2022-08-03 10:38:44 +07:00
parent 2ec37d3e9d
commit ae7f93cb88

View file

@ -977,12 +977,14 @@ function show_tab(target, tabs) {
// mobile navbar appearance control // mobile navbar appearance control
let scrollPos = 0 let scrollPos = 0
if (screen.width < 992) {
document.addEventListener('scroll', (e) => { document.addEventListener('scroll', (e) => {
if (document.documentElement.scrollTop - scrollPos > 20) { if (document.documentElement.scrollTop - scrollPos > 20) {
document.getElementById("mobile-navbar").style.display = "none"; document.getElementById("mobile-navbar").style.display = "none";
document.getElementById("mobile-navbar-dropdown").style.display = "none"; document.getElementById("mobile-navbar-dropdown").style.display = "none";
} else if (document.documentElement.scrollTop - scrollPos < -50) { } else if (document.documentElement.scrollTop - scrollPos < -50 || scrollPos < 70) {
document.getElementById("mobile-navbar").style.display = ""; document.getElementById("mobile-navbar").style.display = "";
} }
scrollPos = document.documentElement.scrollTop; scrollPos = document.documentElement.scrollTop;
}); });
}