Files
knaeckeboot-eu/themes/bluewater/static/js/top-arrow.js
T
Konstantin Kollar 8529ee86e4 Initial commit
2022-10-03 21:13:35 +02:00

18 lines
520 B
JavaScript

var toTopButton = document.getElementById("to-top-button");
// When the user scrolls down 200px from the top of the document, show the button
window.onscroll = function () {
if (
document.body.scrollTop > 250 ||
document.documentElement.scrollTop > 250
) {
toTopButton.classList.remove("hidden");
} else {
toTopButton.classList.add("hidden");
}
};
// When the user clicks on the button, scroll to the top of the document
function goToTop() {
window.scrollTo({ top: 0, behavior: "smooth" });
}