feat: scrolling to the top don't hide the TOC when banner is disabled
This commit is contained in:
parent
e1a98c4149
commit
201f4c8e23
@ -413,18 +413,18 @@ const setup = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
window.swup.hooks.on('visit:end', (visit: {to: {url: string}}) => {
|
window.swup.hooks.on('visit:end', (visit: {to: {url: string}}) => {
|
||||||
// execute 1s later
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const heightExtend = document.getElementById('page-height-extend')
|
const heightExtend = document.getElementById('page-height-extend')
|
||||||
if (heightExtend) {
|
if (heightExtend) {
|
||||||
heightExtend.classList.add('hidden')
|
heightExtend.classList.add('hidden')
|
||||||
}
|
}
|
||||||
}, 200)
|
|
||||||
|
|
||||||
const toc = document.getElementById('toc-wrapper');
|
// Just make the transition looks better
|
||||||
if (toc) {
|
const toc = document.getElementById('toc-wrapper');
|
||||||
toc.classList.remove('toc-not-ready')
|
if (toc) {
|
||||||
}
|
toc.classList.remove('toc-not-ready')
|
||||||
|
}
|
||||||
|
}, 200)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (window?.swup?.hooks) {
|
if (window?.swup?.hooks) {
|
||||||
@ -447,7 +447,7 @@ function scrollFunction() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toc) {
|
if (bannerEnabled && toc) {
|
||||||
if (document.body.scrollTop > bannerHeight || document.documentElement.scrollTop > bannerHeight) {
|
if (document.body.scrollTop > bannerHeight || document.documentElement.scrollTop > bannerHeight) {
|
||||||
toc.classList.remove('toc-hide')
|
toc.classList.remove('toc-hide')
|
||||||
} else {
|
} else {
|
||||||
|
@ -93,9 +93,11 @@ const mainPanelTop = siteConfig.banner.enable ? `calc(${BANNER_HEIGHT}vh - ${MAI
|
|||||||
<div class="absolute w-full z-0">
|
<div class="absolute w-full z-0">
|
||||||
<div class="relative max-w-[var(--page-width)] mx-auto">
|
<div class="relative max-w-[var(--page-width)] mx-auto">
|
||||||
<!-- TOC component -->
|
<!-- TOC component -->
|
||||||
{siteConfig.toc.enable && <div id="toc-wrapper" class="transition absolute top-0 -right-[var(--toc-width)] w-[var(--toc-width)] flex items-center toc-hide">
|
{siteConfig.toc.enable && <div id="toc-wrapper" class:list={["transition absolute top-0 -right-[var(--toc-width)] w-[var(--toc-width)] flex items-center",
|
||||||
|
{"toc-hide": siteConfig.banner.enable}]}
|
||||||
|
>
|
||||||
<div id="toc-inner-wrapper" class="fixed top-14 w-[var(--toc-width)] h-[calc(100vh_-_20rem)] overflow-y-scroll overflow-x-hidden hide-scrollbar">
|
<div id="toc-inner-wrapper" class="fixed top-14 w-[var(--toc-width)] h-[calc(100vh_-_20rem)] overflow-y-scroll overflow-x-hidden hide-scrollbar">
|
||||||
<div id="toc" class="w-full h-full transition-swup-fade">
|
<div id="toc" class="w-full h-full transition-swup-fade ">
|
||||||
<div class="h-8 w-full"></div>
|
<div class="h-8 w-full"></div>
|
||||||
<TOC headings={headings}></TOC>
|
<TOC headings={headings}></TOC>
|
||||||
<div class="h-8 w-full"></div>
|
<div class="h-8 w-full"></div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user