fix: clicking on a same path hash in the search box does not jump

pull/2527/head
zonemeen 3 years ago
parent 51661def8f
commit 41cca89d48

@ -269,15 +269,21 @@ export function scrollTo(el: Element, hash: string, smooth = false) {
offset +
targetPadding
// only smooth scroll if distance is smaller than screen height.
if (!smooth || Math.abs(targetTop - window.scrollY) > window.innerHeight) {
window.scrollTo(0, targetTop)
} else {
window.scrollTo({
left: 0,
top: targetTop,
behavior: 'smooth'
})
function scrollToTarget() {
if (
!smooth ||
Math.abs(targetTop - window.scrollY) > window.innerHeight
) {
window.scrollTo(0, targetTop)
} else {
window.scrollTo({
left: 0,
top: targetTop,
behavior: 'smooth'
})
}
}
requestAnimationFrame(scrollToTarget)
}
}

Loading…
Cancel
Save