Files
Krzak.org/animations.js
2025-10-30 08:41:03 +01:00

32 lines
751 B
JavaScript

(function () {
const backToTopButton = document.getElementById("back-to-top");
if (backToTopButton) {
function toggleBackToTop() {
if (window.pageYOffset > 300) {
backToTopButton.classList.add("visible");
} else {
backToTopButton.classList.remove("visible");
}
}
backToTopButton.addEventListener("click", function () {
window.scrollTo({
top: 0,
behavior: "smooth",
});
});
window.addEventListener("scroll", toggleBackToTop);
toggleBackToTop();
}
const listItems = document.querySelectorAll("li");
listItems.forEach((item, index) => {
if (!item.style.animationDelay) {
item.style.animationDelay = `${0.1 + index * 0.05}s`;
}
});
})();