diff --git a/resources/js/singles/sommaire.ts b/resources/js/singles/sommaire.ts index 9b8bb13..1345521 100644 --- a/resources/js/singles/sommaire.ts +++ b/resources/js/singles/sommaire.ts @@ -2,7 +2,13 @@ export function handleSmoothScrollToTitle(targetId: string): void { const targetElement = document.querySelector(`#${targetId}`); if (!targetElement) return; - targetElement.scrollIntoView({ behavior: 'smooth' }); + const elementRect = targetElement.getBoundingClientRect(); + const offset = 30; // 10px offset from top + + window.scrollTo({ + top: window.pageYOffset + elementRect.top - offset, + behavior: 'smooth', + }); } // Fonction équivalente à sanitize_title() de WordPress