-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
68 lines (59 loc) · 1.85 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
let letters = Array.from(document.querySelectorAll(".letters"));
letters.forEach((a) => {
a.innerHTML = a.textContent
.split(" ")
.map((word) => {
if (word[0] != "&") {
return `<span class="sp">${word[0]}</span>${word.substring(1)}`;
} else {
return word;
}
})
.join(" ");
});
let btn = document.querySelector(".icon");
let span = document.querySelectorAll(".letters span");
let border = document.querySelector(".borderBottom");
let flag = true;
btn.addEventListener("click", function () {
flag = !flag;
if (flag == false) {
border.classList.remove("borderBottomAnimOut");
border.classList.add("borderBottomAnimIn");
letters.forEach((a) => {
a.classList.remove("lettersOff");
});
letters.forEach((a) => {
a.classList.add("lettersOn");
});
span.forEach(function (x, index) {
// Foreach with delay
setTimeout(function () {
x.classList.remove("fallDown");
}, 100 * index);
});
span.forEach(function (x, index) {
setTimeout(function () {
x.classList.add("fallUp");
}, 100 * index);
});
} else {
border.classList.remove("borderBottomAnimIn");
border.classList.add("borderBottomAnimOut");
letters.forEach((a) => {
a.classList.remove("lettersOn");
});
letters.forEach((a) => {
a.classList.add("lettersOff");
});
span.forEach((x) => {
x.classList.remove("fallUp");
});
span.forEach(function (x, index) {
// Foreach with delay
setTimeout(function () {
x.classList.add("fallDown");
}, 50 * index);
});
}
});