Files
SnowLuma/.pnpm-store/v11/files/92/bc808f71496ce07d512a1cfe2ad8555d9dff6730425f75dcc1e1a1bd7ce0f9f5a12f42e88021da003a067995449610239aa891e200f38139134586858f9928
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

22 lines
696 B
Plaintext

import type { AnyRouter } from './router'
/**
* @private
* Handles hash-based scrolling after navigation completes.
* To be used in framework-specific <Transitioner> components during the onResolved event.
*/
export function handleHashScroll(router: AnyRouter) {
if (typeof document !== 'undefined' && (document as any).querySelector) {
const location = router.stores.location.get()
const hashScrollIntoViewOptions =
location.state.__hashScrollIntoViewOptions ?? true
if (hashScrollIntoViewOptions && location.hash !== '') {
const el = document.getElementById(location.hash)
if (el) {
el.scrollIntoView(hashScrollIntoViewOptions)
}
}
}
}