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 pathname = usePathname();
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() {
setHasInteracted(true);
setShowMenu(!showMenu);
}
@@ -61,6 +65,7 @@ export const Header = () => {
<header
className={styles.header}
data-show={showMenu}
data-animate={hasInteracted}
data-small={!isInView}
>
<Link href="/" aria-label="Hjem">
+7 -1
View File
@@ -54,6 +54,12 @@
transition: transform .6s ease;
}
}
&[data-animate=false] {
.mainMenu {
animation: none;
}
}
}
.overlay {
@@ -282,4 +288,4 @@
.logo {
font-size: 1rem;
}
}
}