FEATURE Introducing dedicated external component to handle the sommaire features
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
8fcc797381
commit
4e66d244ee
16
resources/js/singles/sommaire.ts
Normal file
16
resources/js/singles/sommaire.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
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' });
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user