|
|
@ -269,7 +269,11 @@ export function scrollTo(el: Element, hash: string, smooth = false) {
|
|
|
|
offset +
|
|
|
|
offset +
|
|
|
|
targetPadding
|
|
|
|
targetPadding
|
|
|
|
// only smooth scroll if distance is smaller than screen height.
|
|
|
|
// only smooth scroll if distance is smaller than screen height.
|
|
|
|
if (!smooth || Math.abs(targetTop - window.scrollY) > window.innerHeight) {
|
|
|
|
function scrollToTarget() {
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
!smooth ||
|
|
|
|
|
|
|
|
Math.abs(targetTop - window.scrollY) > window.innerHeight
|
|
|
|
|
|
|
|
) {
|
|
|
|
window.scrollTo(0, targetTop)
|
|
|
|
window.scrollTo(0, targetTop)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
window.scrollTo({
|
|
|
|
window.scrollTo({
|
|
|
@ -279,6 +283,8 @@ export function scrollTo(el: Element, hash: string, smooth = false) {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
requestAnimationFrame(scrollToTarget)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function tryOffsetSelector(selector: string): number {
|
|
|
|
function tryOffsetSelector(selector: string): number {
|
|
|
|