FEATURE Handling an offset when scrolling to anchor to improve readability
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
1be03a7641
commit
017555b92e
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user