window.addEventListener('resize', function() {
console.log('resizing');
document.addEventListener('scroll', function() {
checkScrollHeight();
});
});
function checkScrollHeight() {
let stickyNavbar = document.getElementById('sticky-navbar');
let currentPosition = window.pageYOffset || document.documentElement.scrollTop;
let bannerHeight = document.getElementById('banner-height').offsetHeight || document.getElementById('banner-height').clientHeight;
if(currentPosition > bannerHeight) {
stickyNavbar.style.display = "block";
return;
} else {
stickyNavbar.style.display = "none";
}
}
When the screenwidth has been resized, it would run the function, but I am now looking for a way to run the function as well when someone only refreshes the page.