refactor: remove requestAnimationFrame and highlight delay from scrollInContainerToElement

This commit is contained in:
neerajadhav 2025-07-08 18:21:14 +05:30
parent d6219339ef
commit 4db33faff7
2 changed files with 11 additions and 16 deletions

View File

@ -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))

View File

@ -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)
}
})
}