As a graphic designer with some coding knowledge, I'm struggling with a particular issue...
I have a traditional navigation bar that only appears when the user scrolls down a bit, which I achieved through JavaScript. However, I want this to occur only in the middle of each page - around 100px from the top and 100px from the bottom of the scroll. This is because I already have breadcrumbs at the top and a footer at the bottom, making the navigation bar unnecessary in those areas.
I've attempted to combine the navbar with scroll detectors or read scroll position bars, but I haven't been able to make anything work...
Any assistance would be greatly appreciated!
Here is my current code for the navbar (suggestions for improvements are also welcome):
var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("navbar").style.bottom = "0";
} else {
document.getElementById("navbar").style.bottom = "-100px";
}
prevScrollpos = currentScrollPos;
}