I would like to make a header that when scrolling down the scroll bar, it compresses its contents. I have the following script so far.
window.scroll(function() {
var scroll = window.scrollTop();
var element = document.getElementById("nav");
if (scroll >= 140) {
element.classList.add("rola");
} else {
element.classList.remove("rola");;
}
});
I know that the HTML
components are loaded after the window
object, so how would I proceed with script ? I do not know how to wait for the component to load.