forked from Anushkabh/krishiconnect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
28 lines (23 loc) · 999 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
document.addEventListener("DOMContentLoaded", function() {
const loader = document.getElementById("loader");
const headings = loader.querySelectorAll("h3");
// Function to add class with staggered timing
const staggeredClassAddition = (elements, className, delay) => {
elements.forEach((element, index) => {
setTimeout(() => {
element.classList.add(className);
element.style.opacity = 1; // Ensure opacity is set to 1
}, index * delay);
});
};
// Add initial animation classes
staggeredClassAddition(headings, "animate", 500);
// Fade out the loader after animations complete
setTimeout(() => {
loader.classList.add("fade-out");
}, 2000); // Total animation duration: 3 * 500ms = 1500ms, add some buffer
// Hide the loader after fade-out animation completes
setTimeout(() => {
loader.classList.add("hidden");
}, 3000); // 2000ms (fade-out duration) + 1000ms (buffer)
});