REFACTOR Fixing duplicate handleSmoothScrollToTitle function
This commit is contained in:
parent
4e66d244ee
commit
6d12445569
|
|
@ -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<Element> = document.querySelectorAll('.sommaire-index li a');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,6 @@
|
|||
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();
|
||||
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' });
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user