回答編集履歴
1
同じ要素をクリックしたときに閉じるという動作を加えました。
test
CHANGED
@@ -2,36 +2,36 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
|
5
|
+
function toggleOpen() {
|
6
6
|
|
7
|
-
|
7
|
+
panels.forEach(panel => panel.classList.remove("open"));
|
8
8
|
|
9
|
-
|
9
|
+
this.classList.add("open");
|
10
10
|
|
11
|
-
|
11
|
+
if(this.classList.contains("open-active")){
|
12
12
|
|
13
|
-
|
13
|
+
this.classList.remove("open");
|
14
14
|
|
15
|
-
|
15
|
+
}
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
});
|
20
|
-
|
21
|
-
};
|
17
|
+
};
|
22
18
|
|
23
19
|
|
24
20
|
|
25
|
-
function toggleActive(e){
|
26
21
|
|
27
|
-
if(e.propertyName.includes('flex-grow')){
|
28
22
|
|
29
|
-
|
23
|
+
function toggleActive(e){
|
30
24
|
|
31
|
-
|
25
|
+
if(e.propertyName.includes('flex-grow')){
|
32
26
|
|
33
|
-
|
27
|
+
this.classList.toggle("open-active");
|
34
28
|
|
35
|
-
|
29
|
+
}
|
36
30
|
|
31
|
+
}
|
32
|
+
|
33
|
+
|
34
|
+
|
37
|
-
toggleOpen
|
35
|
+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
|
36
|
+
|
37
|
+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
|