auto-claude: subtask-3-1 - Apply throttle to Header scroll event listener
This commit is contained in:
@@ -18,6 +18,7 @@ import { usePathname } from 'next/navigation';
|
|||||||
import { NavLink } from './NavLink';
|
import { NavLink } from './NavLink';
|
||||||
import LanguageSwitcher from './LanguageSwitcher';
|
import LanguageSwitcher from './LanguageSwitcher';
|
||||||
import { ContactInfo } from './ContactInfo';
|
import { ContactInfo } from './ContactInfo';
|
||||||
|
import { throttle } from '@/utils/throttle';
|
||||||
|
|
||||||
const Header = () => {
|
const Header = () => {
|
||||||
const t = useTranslations('navigation');
|
const t = useTranslations('navigation');
|
||||||
@@ -33,9 +34,9 @@ const Header = () => {
|
|||||||
|
|
||||||
// Scroll handler
|
// Scroll handler
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleScroll = () => {
|
const handleScroll = throttle(() => {
|
||||||
setScrolled(window.scrollY > 0);
|
setScrolled(window.scrollY > 0);
|
||||||
};
|
}, 100);
|
||||||
window.addEventListener('scroll', handleScroll);
|
window.addEventListener('scroll', handleScroll);
|
||||||
return () => window.removeEventListener('scroll', handleScroll);
|
return () => window.removeEventListener('scroll', handleScroll);
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
Reference in New Issue
Block a user