perf(thermal): eradicate thermal heating, CPU throttling, and excessive power draw across mobile and low-end devices
This commit is contained in:
@@ -29,8 +29,16 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
const pathname = usePathname();
|
||||
|
||||
useEffect(() => {
|
||||
let lastScrolled = window.scrollY > 20;
|
||||
if (lastScrolled !== isScrolled) {
|
||||
setIsScrolled(lastScrolled);
|
||||
}
|
||||
const handleScroll = () => {
|
||||
setIsScrolled(window.scrollY > 20);
|
||||
const nextScrolled = window.scrollY > 20;
|
||||
if (nextScrolled !== lastScrolled) {
|
||||
lastScrolled = nextScrolled;
|
||||
setIsScrolled(nextScrolled);
|
||||
}
|
||||
};
|
||||
window.addEventListener('scroll', handleScroll, { passive: true });
|
||||
return () => window.removeEventListener('scroll', handleScroll);
|
||||
|
||||
Reference in New Issue
Block a user