Closed moeenxyz closed 3 years ago
@zutrinken can you please help me about this?
window.addEventListener('scroll', stickynav);
var navbar = document.getElementById("nav");
var sticky = nav.offsetTop;
function stickynav() {
if (window.scrollY > sticky) {
navbar.classList.add("stickynav")
navbar.classList.remove("navbottom")
} else {
navbar.classList.add("navbottom")
navbar.classList.remove("stickynav");
}
}
stickynav();
my code is like this, I changed the reload function as this:
function reload() {
grid();
ajaxLinkClass();
highlight();
gallery();
video();
comments();
stickynav();
}
but it doesn't work.
Can't test it at the moment, but looks like var navbar
and var sticky
are undefined after reload. Also the EventListener probably has to go into the reload function, but separately.
Hello, I use a .js file in order to stick the navbar to the top of screen after scroll, it works fine when the page load, but e.g. when I go to a post and then click on site title to go back to home page, the js doesn't relaod and therefore don't work. how should I reload it? I try to put the script in script.js but nothing changed.