function posY(elm) { var test = elm, top = 0; while(!!test && test.tagName.toLowerCase() !== "body") { top += test.offsetTop; test = test.offsetParent; } return top; } function viewPortHeight() { var de = document.documentElement; if(!!window.innerWidth) { return window.innerHeight; } else if( de && !isNaN(de.clientHeight) ) { return de.clientHeight; } return 0; } function scrollY() { if( window.pageYOffset ) { return window.pageYOffset; } return Math.max(document.documentElement.scrollTop, document.body.scrollTop); } function checkvisible( elm ) { var vpH = viewPortHeight(), // Viewport Height st = scrollY(), // Scroll Top y = posY(elm); return (y > (vpH + st)); } document.body.innerHTML = document.body.innerHTML.replaceAll("\n", "").replace(/> *<").trim(); window.onscroll = () => { if (window.innerWidth > 700) { if (window.scrollY() > (window.innerHeight - 52)) { document.getElementsByClassName("navbar")[0].classList.add("scrolled"); } else { document.getElementsByClassName("navbar")[0].classList.remove("scrolled"); } } else { if (window.scrollY() > (window.innerHeight - 120)) { document.getElementsByClassName("navbar")[0].classList.add("scrolled"); } else { document.getElementsByClassName("navbar")[0].classList.remove("scrolled"); } } }