Skip to content

Commit 2dacec6

Browse files
author
linuxjava7
committed
Create animation.js
1 parent c4ae0f2 commit 2dacec6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

javascript/animation.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
document.addEventListener("DOMContentLoaded", () => {
2+
const allElements = document.querySelectorAll(
3+
"main h1, main h2, main h3, main h4, main h5, main h6, main p, main li, main .card",
4+
);
5+
6+
let staggerIndex = 0;
7+
8+
allElements.forEach((el) => {
9+
if (el.classList.contains("card") || !el.closest(".card")) {
10+
el.classList.add("appear");
11+
el.style.animationDelay = `${staggerIndex * 150}ms`;
12+
el.style.animationDuration = "800ms";
13+
staggerIndex++;
14+
}
15+
});
16+
});

0 commit comments

Comments
 (0)