Add condition for left sidebar's existence
This commit is contained in:
parent
edef108656
commit
d6b90271b8
13
js/toc.js
13
js/toc.js
|
@ -47,13 +47,24 @@ window.addEventListener('DOMContentLoaded', (event) => {
|
|||
}
|
||||
tocOl.append(tocFragment);
|
||||
toc.append(tocOl);
|
||||
|
||||
const tocClone = tocOl.cloneNode(true);
|
||||
tocSidebar.appendChild(tocClone);
|
||||
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