carhop__dynamiques-theme__P.../resources/js/singles/sommaire.ts
Nonimart 4e66d244ee
All checks were successful
continuous-integration/drone/push Build is passing
FEATURE Introducing dedicated external component to handle the sommaire features
2025-06-24 12:53:36 +02:00

17 lines
523 B
TypeScript

export function handleSmoothScrollToTitle(): void {
const sommaireTitles: NodeListOf<Element> = document.querySelectorAll('.sommaire-index li a');
for (const title of sommaireTitles) {
title.addEventListener('click', (e) => {
e.preventDefault();
const target = title.getAttribute('href');
if (!target) return;
const targetElement = document.querySelector(target);
if (!targetElement) return;
targetElement.scrollIntoView({ behavior: 'smooth' });
});
}
}