"use client"; import { ArrowUpIcon } from "lucide-react"; import { useEffect, useState } from "react"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; export function ScrollToTop() { const [show, setShow] = useState(false); useEffect(() => { const handleScroll = () => { // Check if user has scrolled to bottom const scrolledToBottom = window.innerHeight + window.scrollY >= document.documentElement.scrollHeight - 100; if (scrolledToBottom) { setShow(true); } else { setShow(false); } }; window.addEventListener("scroll", handleScroll); return () => window.removeEventListener("scroll", handleScroll); }, []); const scrollToTop = () => { window.scrollTo({ top: 0, behavior: "smooth" }); }; return (
); }