don't animate menu unless interacted with
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user