This commit is contained in:
Your Name committed 2026-06-19 19:49:51 -04:00
1 parent 716bb98b50
commit cb51c0faeb
11 files changed
+127 -30

No files matched your search

+25 -3
View File
@@ -86,20 +86,42 @@ export default function Navbar({ topOffsetClassName = 'top-0' }: NavbarProps) {
// Keep --navbar-bottom in sync so the fixed mega-menu dropdown sits flush below the navbar
useEffect(() => {
let animationFrameId: number;
const navElement = navRef.current;
const updateNavBottom = () => {
if (navRef.current) {
const bottom = navRef.current.getBoundingClientRect().bottom
if (navElement) {
const bottom = navElement.getBoundingClientRect().bottom
document.documentElement.style.setProperty('--navbar-bottom', `${bottom}px`)
}
}
updateNavBottom()
window.addEventListener('scroll', updateNavBottom, { passive: true })
window.addEventListener('resize', updateNavBottom)
const observer = new ResizeObserver(() => {
cancelAnimationFrame(animationFrameId);
animationFrameId = requestAnimationFrame(updateNavBottom);
});
if (navElement) {
observer.observe(navElement);
navElement.addEventListener('transitionend', updateNavBottom);
}
observer.observe(document.body);
return () => {
window.removeEventListener('scroll', updateNavBottom)
window.removeEventListener('resize', updateNavBottom)
observer.disconnect()
if (navElement) {
navElement.removeEventListener('transitionend', updateNavBottom);
}
cancelAnimationFrame(animationFrameId);
}
}, [])
}, [topOffsetClassName])
useEffect(() => { setMobileOpen(false) }, [navigate])
useEffect(() => {