···66 threshold: number = 0.9,
77) {
88 const element = document.getElementById(elementId);
99- scrollIntoViewIfNeeded(element, false, "smooth");
99+ // Use double requestAnimationFrame to ensure the element is fully painted
1010+ // before attempting to scroll. This fixes smooth scrolling when opening
1111+ // pages from within other pages.
1212+ requestAnimationFrame(() => {
1313+ requestAnimationFrame(() => {
1414+ scrollIntoViewIfNeeded(element, false, "smooth");
1515+ });
1616+ });
1017}