-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
44 lines (43 loc) · 1.23 KB
/
script.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
let i = 0;
const navSlide = () => {
const burger = document.querySelector(".burger");
const nav = document.querySelector(".nav-links");
const navLinks = document.querySelectorAll(".nav-links li");
burger.addEventListener("click", () => {
// Toggle Nav
nav.classList.toggle("nav-active");
// Animate Links
navLinks.forEach((link, index) => {
if (link.style.animation) {
link.style.animation = "";
} else {
link.style.animation = link.style.animation = `navLinkFade 0.5s ease forwards ${
index / 7 + 0.3
}s`;
}
i++;
});
// Burger Animation
burger.classList.toggle("toggle");
});
nav.addEventListener("click", () => {
if (i % 2 != 0) {
// Toggle Nav
nav.classList.toggle("nav-active");
// Animate Links
navLinks.forEach((link, index) => {
if (link.style.animation) {
link.style.animation = "";
} else {
link.style.animation = link.style.animation = `navLinkFade 0.5s ease forwards ${
index / 7 + 0.3
}s`;
}
i++;
});
// Burger Animation
burger.classList.toggle("toggle");
}
});
};
navSlide();