fix(mobile+navbar): remove white cloudy bottom haze, immediate solid navbar transition on scroll, and restore horizontal category scroller on mobile

This commit is contained in:
2026-11-05 17:24:02 +05:30
parent d13008b334
commit acba642b05
4 changed files with 40 additions and 37 deletions
+9 -23
View File
@@ -17,36 +17,22 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
const pathname = usePathname();
// 100% Off-Main-Thread Observer: 0% CPU, 0 Scroll Lag
// Fast, scroll-aware navbar transformation:
// - Homepage at rest (scrollY <= 25): Transparent text buttons over dark hero
// - As soon as scrolled (scrollY > 25) or on any other page: Transforms into solid navbar
useEffect(() => {
// On non-homepage pages, navbar is immediately in solid state
if (pathname !== '/') {
setIsScrolled(true);
return;
}
setIsScrolled(false);
const sentinel = document.getElementById('hero-sentinel');
if (!sentinel) {
const handleScroll = () => {
setIsScrolled(window.scrollY > 400);
};
window.addEventListener('scroll', handleScroll, { passive: true });
return () => window.removeEventListener('scroll', handleScroll);
}
const checkScroll = () => {
setIsScrolled(window.scrollY > 25);
};
const observer = new IntersectionObserver(
([entry]) => {
setIsScrolled(!entry.isIntersecting && entry.boundingClientRect.top < 0);
},
{
threshold: 0,
rootMargin: '-60px 0px 0px 0px',
}
);
observer.observe(sentinel);
return () => observer.disconnect();
checkScroll();
window.addEventListener('scroll', checkScroll, { passive: true });
return () => window.removeEventListener('scroll', checkScroll);
}, [pathname]);
// Close mobile menu on Escape key