mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-19 19:04:06 -06:00
refactor: remove requestAnimationFrame and highlight delay from scrollInContainerToElement
This commit is contained in:
parent
d6219339ef
commit
4db33faff7
@ -130,7 +130,7 @@ async function mouseEnterHandler(
|
||||
const targetID = `popover-internal-${el.id}`
|
||||
el.id = targetID
|
||||
})
|
||||
const elts = Array.from(html.getElementsByClassName("popover-hint"))
|
||||
const elts = [...html.getElementsByClassName("popover-hint")]
|
||||
if (elts.length === 0) return
|
||||
|
||||
elts.forEach((elt) => popoverInner.appendChild(elt))
|
||||
|
||||
@ -161,8 +161,7 @@ export function scrollInContainerToElement(
|
||||
highlight: boolean = true,
|
||||
behavior: ScrollBehavior = "instant",
|
||||
) {
|
||||
// Use requestAnimationFrame to ensure content is rendered before scrolling
|
||||
requestAnimationFrame(() => {
|
||||
// Scroll immediately, since content should already be rendered in a static site
|
||||
const targetPosition = target.offsetTop - buffer
|
||||
container.scroll({
|
||||
top: Math.max(0, targetPosition),
|
||||
@ -171,10 +170,6 @@ export function scrollInContainerToElement(
|
||||
|
||||
// Add highlight effect if requested
|
||||
if (highlight) {
|
||||
// Small delay to ensure scroll completes before highlighting
|
||||
setTimeout(() => {
|
||||
highlightElement(target)
|
||||
}, 50)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user