"use client"; import { useEffect, useRef } from "react"; export function ScrollProgress() { const barRef = useRef(null); useEffect(() => { const update = () => { const h = document.documentElement; const max = h.scrollHeight - h.clientHeight; const pct = max <= 0 ? 0 : Math.min(1, h.scrollTop / max); if (barRef.current) barRef.current.style.width = `${pct * 100}%`; }; update(); window.addEventListener("scroll", update, { passive: true }); window.addEventListener("resize", update); return () => { window.removeEventListener("scroll", update); window.removeEventListener("resize", update); }; }, []); return (
); }