1
0
mirror of https://github.com/osmarks/website synced 2026-03-13 11:49:44 +00:00

fix sidenote layout and performance enhancements

This commit is contained in:
osmarks
2024-10-26 15:14:51 +01:00
parent 6011e27dbd
commit d9a3eeae1e
3 changed files with 13 additions and 4 deletions

View File

@@ -402,6 +402,15 @@ window.points = (async () => {
}
})()
// we don't consider things that might be in a <summary> but it is not relevant here
const inCollapsedDetails = el => {
while (el) {
if (el.nodeName === "DETAILS" && el.open === false) return true
el = el.parentElement
}
return false
}
const footnotes = document.querySelector(".footnotes")
const sidenotes = document.querySelector(".sidenotes")
if (sidenotes && footnotes) {
@@ -427,7 +436,7 @@ if (sidenotes && footnotes) {
const exclusions = [[-Infinity, Math.max(articleRect.top, snRect.top)]]
for (const codeblock of codeblocks) {
const codeblockRect = codeblock.getBoundingClientRect()
if (codeblockRect.width !== 0) { // collapsed
if (codeblockRect.width !== 0 && !inCollapsedDetails(codeblock)) { // collapsed
exclusions.push([codeblockRect.top - BORDER, codeblockRect.top + codeblockRect.height + BORDER])
}
}