Merge pull request #580 from NINE-J/style/sidebar-scroll-behavior

fix: Fix what the navigation hide interaction affects all pages
This commit is contained in:
Shu Yao 2026-03-15 14:49:43 +08:00 committed by GitHub
commit 75e889decf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 6 deletions

View File

@ -61,13 +61,21 @@ const handleScroll = (e) => {
lastScrollY = currentScrollY <= 0 ? 0 : currentScrollY;
}
onMounted(() => {
// Listen to scroll events during the capture phase to track child scrolling (like TutorialView)
window.addEventListener('scroll', handleScroll, true);
})
const toggleScrollListener = (shouldListen) => {
if (shouldListen) {
window.addEventListener('scroll', handleScroll, true);
} else {
window.removeEventListener('scroll', handleScroll, true);
isHidden.value = false; // Reset state when leaving
}
}
watch(() => route.path, () => {
toggleScrollListener(!!route.meta.hideNavOnScroll);
}, { immediate: true }) // immediate: true runs this once on mount
onUnmounted(() => {
window.removeEventListener('scroll', handleScroll, true);
toggleScrollListener(false);
document.body.classList.remove('nav-hidden');
})
</script>

View File

@ -7,7 +7,8 @@ const routes = [
},
{
path: '/tutorial',
component: () => import('../pages/TutorialView.vue')
component: () => import('../pages/TutorialView.vue'),
meta: { hideNavOnScroll: true }
},
{
path: '/launch',