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