animations
This commit is contained in:
31
animations.js
Normal file
31
animations.js
Normal file
@@ -0,0 +1,31 @@
|
||||
(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`;
|
||||
}
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user