(null);
// Check if we're on a project page
const isProjectPage = location.pathname.startsWith('/project/');
+ // Close mobile menu when clicking outside
+ useEffect(() => {
+ const handleClickOutside = (event: MouseEvent) => {
+ if (mobileMenuRef.current && !mobileMenuRef.current.contains(event.target as Node)) {
+ setMobileMenuOpen(false);
+ }
+ };
+
+ if (mobileMenuOpen) {
+ document.addEventListener('mousedown', handleClickOutside);
+ }
+
+ return () => {
+ document.removeEventListener('mousedown', handleClickOutside);
+ };
+ }, [mobileMenuOpen]);
+
const handleNavigation = (section: string) => {
+ // Close mobile menu immediately
+ setMobileMenuOpen(false);
+
+ // Then scroll to section (happens independently)
if (isProjectPage) {
// If on project page, navigate to home with section anchor
navigate(`/#${section}`);
} else {
// If on home page, scroll to section
- scrollToSection(section);
+ // Use setTimeout to ensure scroll happens after menu animation starts
+ setTimeout(() => {
+ scrollToSection(section);
+ }, 100);
}
};
@@ -50,6 +77,7 @@ export const Header = () => {
initial={{ y: -100 }}
animate={{ y: 0 }}
className="fixed top-0 left-0 right-0 z-50 border-b border-border/40 bg-background/80 backdrop-blur-lg"
+ ref={mobileMenuRef}
>
{
AP
+ {/* Desktop Navigation */}
+
+ {/* Mobile Navigation */}
+
+ {mobileMenuOpen && (
+
+
+ {["home", "projects", "skills", "contact"].map((item, i) => (
+ handleNavigation(item)}
+ className="text-left text-base font-medium text-muted-foreground hover:text-foreground transition-colors py-2"
+ >
+ {t(`nav.${item}`)}
+
+ ))}
+
+
+ )}
+
);
};
diff --git a/src/components/ParticlesBackground.tsx b/src/components/ParticlesBackground.tsx
index 2b6b6ab..4056407 100644
--- a/src/components/ParticlesBackground.tsx
+++ b/src/components/ParticlesBackground.tsx
@@ -16,7 +16,7 @@ export const ParticlesBackground = () => {
}, []);
const particlesLoaded = async (container) => {
- console.log(container);
+ // console.log(container);
};
const options = useMemo(