🐛 Fix: toc-auto display error (#21)

This commit is contained in:
Cell
2022-01-07 17:43:08 +08:00
parent f906bf13f0
commit 80d63f6892
4 changed files with 11 additions and 4 deletions
+1
View File
@@ -5,6 +5,7 @@
- :tada: Feat: add PWA support
- :bug: Fix: add scroll-margin to headerlink
- :bug: Fix: Check if content is empty beforing passing
- :bug: Fix: toc-auto display error ([#21](https://github.com/Lruihao/FixIt/issues/21))
- :fire: Feat: remove lib smooth-scroll ([#1](https://github.com/Lruihao/FixIt/issues/1))
- :lipstick: Style: change scroll-behavior to smooth
- :lipstick: Style: page image margin
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+8 -2
View File
@@ -396,7 +396,14 @@ class Theme {
initToc() {
const $tocCore = document.getElementById('TableOfContents');
if ($tocCore === null) return;
if ($tocCore === null){
return;
}
const $toc = document.getElementById('toc-auto');
if ($tocCore.innerText === ''){
$toc.style.display = 'none';
return;
}
if (document.getElementById('toc-static').getAttribute('kept') || this.util.isTocStatic()) {
const $tocContentStatic = document.getElementById('toc-content-static');
if ($tocCore.parentElement !== $tocContentStatic) {
@@ -410,7 +417,6 @@ class Theme {
$tocCore.parentElement.removeChild($tocCore);
$tocContentAuto.appendChild($tocCore);
}
const $toc = document.getElementById('toc-auto');
const $page = document.getElementsByClassName('page')[0];
const rect = $page.getBoundingClientRect();
$toc.style.left = `${rect.left + rect.width + 20}px`;