🐛 Fix: toc margin bottom calculate error

This commit is contained in:
Cell
2022-02-20 16:33:50 +08:00
parent 4eee19340b
commit aae810b8ed
4 changed files with 9 additions and 7 deletions
+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
+1 -1
View File
@@ -496,7 +496,7 @@ enableEmoji = true
images = ["/logo.png"]
# enable PWA since v0.2.12
# 开启 PWA 支持 since v0.2.12
enablePWA = false
enablePWA = true
# Header config
# 页面头部导航栏配置
+6 -4
View File
@@ -513,10 +513,7 @@ class Theme {
document.querySelector('.single-title').clientHeight +
document.querySelector('.post-meta').clientHeight +
'px';
$toc.style.marginBottom =
document.getElementById('post-footer').clientHeight +
document.getElementById('comments').clientHeight +
'px';
$toc.style.marginBottom = document.getElementById('post-footer').clientHeight + 'px';
const $tocLinkElements = $tocCore.querySelectorAll('a:first-child');
const $tocLiElements = $tocCore.getElementsByTagName('li');
const $headerLinkElements = document.getElementsByClassName('header-link');
@@ -525,6 +522,11 @@ class Theme {
this._tocOnScroll =
this._tocOnScroll ||
(() => {
const $comments = document.getElementById('comments');
if ($comments) {
$toc.style.marginBottom =
document.getElementById('post-footer').clientHeight + $comments.clientHeight + 'px';
}
this.util.forEach($tocLinkElements, ($tocLink) => {
$tocLink.classList.remove('active');
});