diff --git a/src/common/components/Navigation/Navigation.jsx b/src/common/components/Navigation/Navigation.jsx index 33359a7..bdc2f4f 100644 --- a/src/common/components/Navigation/Navigation.jsx +++ b/src/common/components/Navigation/Navigation.jsx @@ -2,6 +2,7 @@ import "./styles.sass"; import Button from "@/common/components/Button"; import SheepstarSitting from "@/assets/SheepstarSitting.png"; import {Link, NavLink} from "react-router-dom"; +import {useEffect, useState} from "react"; const links = [ {name: "Home", to: "/"}, @@ -12,8 +13,22 @@ const links = [ ]; const Navigation = () => { + const [hide, setHidden] = useState(false); + const [lastScrollY, setLastScrollY] = useState(0); + + const scrollHandler = () => { + setHidden(window.scrollY > lastScrollY); + setLastScrollY(window.scrollY); + } + + useEffect(() => { + window.addEventListener('scroll', scrollHandler); + + return () => window.removeEventListener('scroll', scrollHandler); + }, [lastScrollY]); + return ( -
+
Sheepstar Logo