fix: parent element not found error

pull/149/head
Kia King Ishii 5 years ago
parent ecca70ebd4
commit f1857a10fe

@ -96,14 +96,16 @@ function isAnchorActive(
nextAnchor: HTMLAnchorElement
): [boolean, string | null] {
const scrollTop = window.scrollY
const anchorTop = getAnchorTop(anchor)
const nextAnchorTop = getAnchorTop(nextAnchor)
if (index === 0 && scrollTop === 0) {
return [true, null]
}
if (scrollTop >= anchorTop && (!nextAnchor || scrollTop < nextAnchorTop)) {
if (scrollTop < getAnchorTop(anchor)) {
return [false, null]
}
if (!nextAnchor || scrollTop < getAnchorTop(nextAnchor)) {
return [true, decodeURIComponent(anchor.hash)]
}

Loading…
Cancel
Save