"use client";
import React, { useState } from "react";
import {
motion,
AnimatePresence,
useScroll,
useMotionValueEvent,
} from "motion/react";
import { cn } from "@/lib/utils";
const HomeIcon = () => 🏠;
const ServicesIcon = () => 🛠️;
const ProductsIcon = () => 📦;
const ContactIcon = () => 📞;
export const FloatingNav = ({
navItems = [],
className,
}) => {
const { scrollYProgress } = useScroll();
const [visible, setVisible] = useState(false);
useMotionValueEvent(scrollYProgress, "change", (current) => {
if (typeof current === "number") {
let direction = current - scrollYProgress.getPrevious();
if (scrollYProgress.get() < 0.05) {
setVisible(false);
} else {
if (direction < 0) {
setVisible(true);
} else {
setVisible(false);
}
}
}
});
return (