don't animate menu unless interacted with

This commit is contained in:
2026-06-01 03:39:35 +02:00
parent e3a58556f7
commit dcb1a59777
2 changed files with 12 additions and 1 deletions
+5
View File
@@ -25,8 +25,12 @@ export const Header = () => {
const { replace } = useRouter(); const { replace } = useRouter();
const pathname = usePathname(); const pathname = usePathname();
const [showMenu, setShowMenu] = useState(false); const [showMenu, setShowMenu] = useState(false);
// Only enable the menu's slide/fade animations once the user has interacted,
// so they don't play on first page load
const [hasInteracted, setHasInteracted] = useState(false);
function toggleMenu() { function toggleMenu() {
setHasInteracted(true);
setShowMenu(!showMenu); setShowMenu(!showMenu);
} }
@@ -61,6 +65,7 @@ export const Header = () => {
<header <header
className={styles.header} className={styles.header}
data-show={showMenu} data-show={showMenu}
data-animate={hasInteracted}
data-small={!isInView} data-small={!isInView}
> >
<Link href="/" aria-label="Hjem"> <Link href="/" aria-label="Hjem">
@@ -54,6 +54,12 @@
transition: transform .6s ease; transition: transform .6s ease;
} }
} }
&[data-animate=false] {
.mainMenu {
animation: none;
}
}
} }
.overlay { .overlay {