Я новичок в JavaScript и все еще выясняю.
Мне удалось заставить свою навигацию появляться только сверху и при прокрутке. Проблема в том, что мне нужно, чтобы он вернулся к прозрачному фону, как только он окажется сверху, но он останется серым после того, как изменения начнутся.
/* When the user scrolls down, hide the navbar. When the user scrolls up, show the navbar */
var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("navbar").style.top = "0";
document.getElementById("navbar").style.background = "#2b2b2b";
document.getElementById("totop").style.bottom = "-120px";
} else {
document.getElementById("navbar").style.top = "-50px";
document.getElementById("navbar").style.background = "transparent";
document.getElementById("totop").style.bottom = "0px";
}
prevScrollpos = currentScrollPos;
}