diff --git a/components/Navbar.jsx b/components/Navbar.jsx index aeaf362..41ef1b3 100644 --- a/components/Navbar.jsx +++ b/components/Navbar.jsx @@ -1,5 +1,7 @@ +"use client"; + import Link from "next/link"; -import React from "react"; +import React, { useEffect, useState } from "react"; import Image from "next/image"; import { ModeToggle } from "./ModeToggle"; import { Button } from "../components/ui/button"; @@ -15,8 +17,32 @@ import { import { AlignJustify } from "lucide-react"; const Navbar = () => { + const [scrolled, setScrolled] = useState(false); + + useEffect(() => { + const handleScroll = () => { + const offset = window.scrollY; + if (offset > 50) { + setScrolled(true); + } else { + setScrolled(false); + } + }; + + window.addEventListener("scroll", handleScroll); + return () => { + window.removeEventListener("scroll", handleScroll); + }; + }, []); + + if (scrolled) console.log("scroll triggered"); + return ( -
+
{/* Logo */}