1
0
forked from GitHub/quartz

Compare commits

...

3 Commits

Author SHA1 Message Date
Aaron Pham
205ae02038
chore: run formatter
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
2024-11-13 11:20:18 -05:00
Aaron Pham
c3fceaba96
chore: bound scroll to preview-container only 2024-11-13 11:17:44 -05:00
Aaron Pham
dd1e26ba42
fix(search): ignore mathml block 2024-11-13 10:55:08 -05:00

View File

@ -397,7 +397,18 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
const highlights = [...preview.querySelectorAll(".highlight")].sort( const highlights = [...preview.querySelectorAll(".highlight")].sort(
(a, b) => b.innerHTML.length - a.innerHTML.length, (a, b) => b.innerHTML.length - a.innerHTML.length,
) )
highlights[0]?.scrollIntoView({ block: "start" }) if (highlights.length > 0) {
const highlight = highlights[0]
const container = preview
if (container && highlight) {
const containerRect = container.getBoundingClientRect()
const highlightRect = highlight.getBoundingClientRect()
// Calculate the scroll position relative to the container
const relativeTop = highlightRect.top - containerRect.top + container.scrollTop
container.scrollTo({ top: relativeTop, behavior: "smooth" })
}
}
} }
async function onType(e: HTMLElementEventMap["input"]) { async function onType(e: HTMLElementEventMap["input"]) {