teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

修正

2021/09/22 12:54

投稿

noel0718
noel0718

スコア20

answer CHANGED
@@ -14,6 +14,14 @@
14
14
  this.tabs.addEventListener('click', this.handleClick.bind(this));
15
15
  this.panels.addEventListener('transitionend', this.handleTransition.bind(this));
16
16
  }
17
+ init() {
18
+ if (!this.element.classList.contains('is-active')){
19
+ this.close();
20
+ }else{
21
+ this.open();
22
+ this.height = this.panels.scrollHeight;
23
+ }
24
+ }
17
25
  handleClick() {
18
26
  if (this.isOpen) {
19
27
  this.close();
@@ -34,14 +42,6 @@
34
42
  this.panels.style.maxHeight = `${this.height}px`;
35
43
  }, 1);
36
44
  }
37
- init() {
38
- if (!this.element.classList.contains('is-active')){
39
- this.close();
40
- }else{
41
- this.open();
42
- this.height = this.panels.scrollHeight;
43
- }
44
- }
45
45
  close() {
46
46
  this.isOpen = false;
47
47
  this.panels.style.maxHeight = `${this.height}px`;

1

修正

2021/09/22 12:54

投稿

noel0718
noel0718

スコア20

answer CHANGED
@@ -54,7 +54,6 @@
54
54
  handleTransition() {
55
55
  if (!this.isOpen) {
56
56
  this.element.classList.add('is-hidden');
57
-
58
57
  this.element.classList.remove('is-active');
59
58
  }
60
59
  this.panels.style.maxHeight = '';