Add condition for left sidebar's existence
This commit is contained in:
parent
edef108656
commit
d6b90271b8
11
js/toc.js
11
js/toc.js
|
@ -47,13 +47,24 @@ window.addEventListener('DOMContentLoaded', (event) => {
|
|||
}
|
||||
tocOl.append(tocFragment);
|
||||
toc.append(tocOl);
|
||||
|
||||
const tocClone = tocOl.cloneNode(true);
|
||||
if (tocSidebar) {
|
||||
tocSidebar.appendChild(tocClone);
|
||||
}
|
||||
} else {
|
||||
toc.classList.add('hidden');
|
||||
leftSidebar.classList.add('hidden');
|
||||
}
|
||||
|
||||
// Close article ToC accordion and the left sidebar for small screen sizes
|
||||
if (window.innerWidth < 480) {
|
||||
toc.removeAttribute("open");
|
||||
leftSidebar.classList.add("hidden");
|
||||
} else {
|
||||
toc.setAttribute("open", true);
|
||||
}
|
||||
|
||||
// Remove the stickiness of the sidebar ToC if it is larger than screen height
|
||||
function preventSidebarOverflow() {
|
||||
if (document.documentElement.clientHeight < tocSidebar.offsetHeight + 50) {
|
||||
|
|
Loading…
Reference in New Issue