diff --git a/resources/js/singles/index-panel.ts b/resources/js/singles/index-panel.ts index 4a6b473..9681f00 100644 --- a/resources/js/singles/index-panel.ts +++ b/resources/js/singles/index-panel.ts @@ -69,12 +69,6 @@ function observeSommaireLinks(): void { } } -function handleSmoothScrollToTitle(targetId: string): void { - const targetElement = document.querySelector(`#${targetId}`); - if (!targetElement) return; - - targetElement.scrollIntoView({ behavior: 'smooth' }); -} function toggleActiveChapterLinkInIndexPanel(targetId: string): void { const sommaireLinks: NodeListOf = document.querySelectorAll('.sommaire-index li a'); diff --git a/resources/js/singles/sommaire.ts b/resources/js/singles/sommaire.ts index dda7980..9a4212c 100644 --- a/resources/js/singles/sommaire.ts +++ b/resources/js/singles/sommaire.ts @@ -1,16 +1,6 @@ -export function handleSmoothScrollToTitle(): void { - const sommaireTitles: NodeListOf = document.querySelectorAll('.sommaire-index li a'); - for (const title of sommaireTitles) { - title.addEventListener('click', (e) => { - e.preventDefault(); +export function handleSmoothScrollToTitle(targetId: string): void { + const targetElement = document.querySelector(`#${targetId}`); + if (!targetElement) return; - const target = title.getAttribute('href'); - if (!target) return; - - const targetElement = document.querySelector(target); - if (!targetElement) return; - - targetElement.scrollIntoView({ behavior: 'smooth' }); - }); - } + targetElement.scrollIntoView({ behavior: 'smooth' }); }