fix(scroll): always scroll to hash

pull/277/head
Eduardo San Martin Morote 5 years ago
parent 7185fa6c92
commit 7bb3a48637

@ -132,10 +132,16 @@ export function createRouter(
e.preventDefault() e.preventDefault()
if (pathname === currentUrl.pathname) { if (pathname === currentUrl.pathname) {
// scroll between hash anchors in the same page // scroll between hash anchors in the same page
if (hash && hash !== currentUrl.hash) { if (hash) {
if (hash !== currentUrl.hash) {
history.pushState(null, '', hash) history.pushState(null, '', hash)
}
// use smooth scroll when clicking on header anchor links // use smooth scroll when clicking on header anchor links
scrollTo(link, hash, link.classList.contains('header-anchor')) scrollTo(
link,
decodeURIComponent(hash),
link.classList.contains('header-anchor')
)
} }
} else { } else {
go(href) go(href)

Loading…
Cancel
Save