import { Box, Button, Container, Image } from "@chakra-ui/react"; import React, { useEffect, useState } from "react"; import logo from "../assets/logo.png"; import earth from "../assets/earth.png"; import { Link, NavLink } from "react-router-dom"; import { ChevronDownIcon } from "@chakra-ui/icons"; export const nav = [ { title: "Investment", path: "/investment", }, { title: "How it works", path: "/how-it-works", }, { title: "FAQ", path: "/faq", }, { title: "About Us", path: "/aboutus", }, ]; const Header = () => { const [showHeader, setShowHeader] = useState(true); const [lastScrollY, setLastScrollY] = useState(0); const threshold = 50; // Adjust this value to change sensitivity const controlHeader = () => { if (window.scrollY > lastScrollY + threshold) { setShowHeader(false); } else if (window.scrollY < lastScrollY - threshold) { setShowHeader(true); } setLastScrollY(window.scrollY); }; useEffect(() => { window.addEventListener("scroll", controlHeader); return () => { window.removeEventListener("scroll", controlHeader); }; }, [lastScrollY]); return ( {nav.map(({ title, path }, index) => ( {title} ))} En ); }; export default Header;