diff --git a/theme/src/client/composables/scroll-behavior.ts b/theme/src/client/composables/scroll-behavior.ts index da7c3974..cfaa3f1b 100644 --- a/theme/src/client/composables/scroll-behavior.ts +++ b/theme/src/client/composables/scroll-behavior.ts @@ -4,11 +4,13 @@ import { inBrowser } from '../utils/index.js' import { useScrollPromise } from './scroll-promise.js' export function enhanceScrollBehavior(router: Router) { - // handle scrollBehavior with transition - const scrollBehavior = router.options.scrollBehavior! - router.options.scrollBehavior = async (...args) => { + router.options.scrollBehavior = async (to, from, savedPosition) => { await useScrollPromise().wait() - return scrollBehavior(...args) + if (savedPosition) + return savedPosition + if (to.hash) + return { el: to.hash, top: 64 } + return { top: 0 } } router.beforeEach(() => { diff --git a/theme/src/node/plugins/getPlugins.ts b/theme/src/node/plugins/getPlugins.ts index 0c224ddd..62592caa 100644 --- a/theme/src/node/plugins/getPlugins.ts +++ b/theme/src/node/plugins/getPlugins.ts @@ -47,8 +47,6 @@ export function getPlugins({ activeHeaderLinksPlugin({ headerLinkSelector: 'a.outline-link', headerAnchorSelector: '.header-anchor', - delay: 200, - offset: 5, }), markdownHintPlugin({ hint: true, alert: true, injectStyles: false }),