pull/3654/merge
Bobbie Goede 6 months ago committed by GitHub
commit a8f35dc2ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useScrollLock } from '@vueuse/core' import { useScrollLock } from '@vueuse/core'
import { inBrowser } from 'vitepress' import { inBrowser } from 'vitepress'
import { ref, watch } from 'vue' import { nextTick, onMounted, ref, watch } from 'vue'
import { useSidebar } from '../composables/sidebar' import { useSidebar } from '../composables/sidebar'
import VPSidebarGroup from './VPSidebarGroup.vue' import VPSidebarGroup from './VPSidebarGroup.vue'
@ -35,6 +35,11 @@ watch(
}, },
{ deep: true } { deep: true }
) )
// scroll active link into view
onMounted(() => {
nextTick(() => navEl.value?.querySelector('.is-active')?.scrollIntoView({ block: 'center'}))
})
</script> </script>
<template> <template>

@ -168,6 +168,7 @@ export function useActiveAnchor(
if (activeLink) { if (activeLink) {
activeLink.classList.add('active') activeLink.classList.add('active')
activeLink.scrollIntoView({ behavior: 'smooth', block: 'center' })
marker.value.style.top = activeLink.offsetTop + 39 + 'px' marker.value.style.top = activeLink.offsetTop + 39 + 'px'
marker.value.style.opacity = '1' marker.value.style.opacity = '1'
} else { } else {

Loading…
Cancel
Save