/** * Function to show a scrol lto top button if the user has scrolled down * 250 pixels from teh headline element. */ function scrollToTop() { let headline = document.querySelector(".headline"); let scrollToTop = document.querySelector("#menu-scroll-to-top-div"); window.addEventListener("scroll", (event) => { if (pageYOffset > 250) { scrollToTop.classList.toggle("hide", false); } else { scrollToTop.classList.toggle("hide", true); } }); scrollToTop.onclick = () => { headline.scrollIntoView({behavior: "smooth", block: "end", inline: "nearest"}); }; } // export function export { scrollToTop };