diff --git a/apps/dimentorin/src/app/(public)/_components/header.tsx b/apps/dimentorin/src/app/(public)/_components/header.tsx index 944f1fe..585e126 100644 --- a/apps/dimentorin/src/app/(public)/_components/header.tsx +++ b/apps/dimentorin/src/app/(public)/_components/header.tsx @@ -1,6 +1,7 @@ import { CloseOutlined, MenuOutlined } from "@ant-design/icons"; import { Button } from "@imphnen-frontend-service/ui/atoms"; import { cn, For, Show } from "@imphnen-frontend-service/utils"; +import { motion, useMotionValueEvent, useScroll, Variants } from "framer-motion"; import { FC, useState } from "react"; import { Link, useLocation } from "react-router-dom"; @@ -13,13 +14,30 @@ const MENUS: { label: string; href: string }[] = [ export const Header: FC = () => { const location = useLocation(); + const { scrollY } = useScroll() + const [expandMenu, setExpandMenu] = useState(false); + const [show, setShow] = useState(true) + + const headerVariants: Variants = { + hidden: { opacity: 0, y: -100 }, + show: { opacity: 1, y: 0 }, + }; + + useMotionValueEvent(scrollY, "change", (latest) => { + const prev = scrollY.getPrevious() || 0 + if (latest > prev && latest > 100) setShow(false) + else setShow(true) + }) return ( -