Skip to content
Snippets Groups Projects
Commit 8bfdaa00 authored by Olivia206's avatar Olivia206
Browse files

fixed toc

parent aa2d7f08
No related branches found
No related tags found
No related merge requests found
......@@ -10,9 +10,6 @@ const CLASSES = {
class TableOfContent {
constructor() {
this.element = document.querySelector('.toc-container');
if (!this.element) return;
this.content = this.element.querySelector('.toc-content');
this.nav = this.element.querySelector('.toc');
this.links = this.element.querySelectorAll('a');
......@@ -37,6 +34,12 @@ class TableOfContent {
});
})
this.links.forEach(links => {
links.addEventListener('click', () => {
this.toggle(false);
});
})
window.addEventListener('click', (event) => {
if (event.target === document.body) {
this.toggle(false);
......@@ -62,7 +65,6 @@ class TableOfContent {
this.sections.forEach(section => {
if (section.offsetTop <= scroll) {
id = section.id;
this.toggle(false);
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment