1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-12 01:50:52 +01:00

Fixed invalid anchor list offset for hidden anchors

This commit is contained in:
squidfunk 2020-02-18 17:07:20 +01:00
parent dee75ccfbb
commit d4f5b1377c

View File

@ -132,9 +132,18 @@ export function watchAnchorList(
break
}
}
/* If the current anchor is hidden, continue with its parent */
let offset = target.offsetTop
while (!offset && target.parentElement) {
target = target.parentElement
offset = target.offsetTop
}
/* Map reversed anchor path to vertical offset */
return index.set(
reverse(path = [...path, anchor]),
target.offsetTop
offset
)
}, new Map<HTMLAnchorElement[], number>())
}),