import React, { useEffect, useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import gsap from 'gsap'; const BackToTop: React.FC = () => { const [isVisible, setIsVisible] = useState(false); useEffect(() => { const toggleVisibility = () => { if (window.scrollY > 500) { setIsVisible(true); } else { setIsVisible(false); } }; window.addEventListener('scroll', toggleVisibility); return () => window.removeEventListener('scroll', toggleVisibility); }, []); const scrollToTop = () => { gsap.to(window, { duration: 1.2, scrollTo: 0, ease: "power3.inOut" }); }; return ( {isVisible && ( arrow_upward )} ); }; export default BackToTop;