2023-04-18 17:20:02 -04:00
|
|
|
import {slideUp, slideDown} from '../services/animations';
|
|
|
|
import {Component} from './component';
|
2022-05-18 09:06:40 -04:00
|
|
|
|
2022-11-15 06:24:31 -05:00
|
|
|
export class ChapterContents extends Component {
|
2022-05-18 09:06:40 -04:00
|
|
|
|
|
|
|
setup() {
|
|
|
|
this.list = this.$refs.list;
|
|
|
|
this.toggle = this.$refs.toggle;
|
|
|
|
|
|
|
|
this.isOpen = this.toggle.classList.contains('open');
|
|
|
|
this.toggle.addEventListener('click', this.click.bind(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
open() {
|
|
|
|
this.toggle.classList.add('open');
|
|
|
|
this.toggle.setAttribute('aria-expanded', 'true');
|
|
|
|
slideDown(this.list, 180);
|
|
|
|
this.isOpen = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
close() {
|
|
|
|
this.toggle.classList.remove('open');
|
|
|
|
this.toggle.setAttribute('aria-expanded', 'false');
|
|
|
|
slideUp(this.list, 180);
|
|
|
|
this.isOpen = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
click(event) {
|
|
|
|
event.preventDefault();
|
2023-04-19 10:20:04 -04:00
|
|
|
if (this.isOpen) {
|
|
|
|
this.close();
|
|
|
|
} else {
|
|
|
|
this.open();
|
|
|
|
}
|
2022-05-18 09:06:40 -04:00
|
|
|
}
|
2023-04-18 17:20:02 -04:00
|
|
|
|
2022-05-18 09:06:40 -04:00
|
|
|
}
|