-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path5.js
More file actions
35 lines (31 loc) · 1003 Bytes
/
5.js
File metadata and controls
35 lines (31 loc) · 1003 Bytes
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
function makeItMove() {
const panels = document.querySelectorAll(".panel");
function toggleOff(panels) {
panels.forEach((panel) => {
if (panel.classList.length === 4) {
panel.classList.remove("open");
}
if (panel.classList.value.length === 3) {
panel.classList.remove("open-active");
}
});
}
panels.forEach((panel) =>
panel.addEventListener("click", function () {
if (panel.classList.length === 2) {
panel.classList.add("open");
} else {
panel.classList.remove("open");
}
toggleOff(panels);
})
);
panels.forEach((panel) =>
panel.addEventListener("transitionend", function (e) {
if (e.propertyName.includes("flex")) {
panel.classList.toggle("open-active");
}
})
);
}
window.addEventListener("DOMContentLoaded", makeItMove);