This commit is contained in:
2025-09-17 15:45:33 +02:00
parent 8f997b2f86
commit 9e26dce717
5 changed files with 19 additions and 38 deletions

View File

@@ -1,28 +0,0 @@
import { useEffect } from 'react';
export const useSmoothScroll = () => {
useEffect(() => {
const handleLinkClick = (e: MouseEvent) => {
const target = e.target as HTMLAnchorElement;
const href = target.getAttribute('href');
if (href && href.startsWith('#')) {
e.preventDefault();
const targetId = href.substring(1);
const targetElement = document.getElementById(targetId);
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth',
});
}
}
};
document.addEventListener('click', handleLinkClick);
return () => {
document.removeEventListener('click', handleLinkClick);
};
}, []);
};