Skip to content

Commit

Permalink
fix: emit prevented hashchange event
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Sep 9, 2021
1 parent f079a22 commit 4fb387d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/client/app/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ export function createRouter(
// scroll between hash anchors in the same page
if (hash && hash !== currentUrl.hash) {
history.pushState(null, '', hash)
// still emit the event so we can listen to it in themes
window.dispatchEvent(new Event('hashchange'))
// use smooth scroll when clicking on header anchor links
scrollTo(link, hash, link.classList.contains('header-anchor'))
}
Expand Down

0 comments on commit 4fb387d

Please sign in to comment.