Skip to content

Commit

Permalink
fix(plugin-active-header-links): do not append hash when at top, close
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Feb 26, 2022
1 parent 7342821 commit d5e7d77
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ export const useActiveHeaderLinks = ({
document.body.scrollHeight
)

const isAtPageTop = scrollTop === 0

if (isAtPageTop) {
// make sure route hash is clean
replaceWithoutScrollBehavior(router, {
hash: '',
force: true,
})
return
}

// check if we have reached page bottom
// notice the `scrollBottom` might not be exactly equal to `scrollHeight`, so we add offset here
const isAtPageBottom = Math.abs(scrollHeight - scrollBottom) < offset
Expand Down

0 comments on commit d5e7d77

Please sign in to comment.