MarseyWorld/files/assets/js/mobile_navigation_bar.js

44 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-07-16 21:00:02 +00:00
var prevScrollpos = window.pageYOffset;
window.onscroll = function () {
var currentScrollPos = window.pageYOffset;
var topBar = document.getElementById("fixed-bar-mobile");
var bottomBar = document.getElementById("mobile-bottom-navigation-bar");
var dropdown = document.getElementById("mobileSortDropdown");
var navbar = document.getElementById("navbar");
if (bottomBar != null) {
if (prevScrollpos > currentScrollPos && (window.innerHeight + currentScrollPos) < (document.body.offsetHeight - 65)) {
bottomBar.style.bottom = "0px";
2022-09-04 23:15:37 +00:00
}
2022-07-16 21:00:02 +00:00
else if (currentScrollPos <= 125 && (window.innerHeight + currentScrollPos) < (document.body.offsetHeight - 65)) {
bottomBar.style.bottom = "0px";
}
else if (prevScrollpos > currentScrollPos && (window.innerHeight + currentScrollPos) >= (document.body.offsetHeight - 65)) {
bottomBar.style.bottom = "-50px";
}
else {
bottomBar.style.bottom = "-50px";
}
}
if (topBar != null && dropdown != null) {
if (prevScrollpos > currentScrollPos) {
topBar.style.top = "48px";
navbar.classList.remove("shadow");
2022-09-04 23:15:37 +00:00
}
2022-07-16 21:00:02 +00:00
else if (currentScrollPos <= 125) {
topBar.style.top = "48px";
navbar.classList.remove("shadow");
}
else {
topBar.style.top = "-48px";
dropdown.classList.remove('show');
navbar.classList.add("shadow");
}
}
prevScrollpos = currentScrollPos;
}