diff --git a/app/components/ScrollUpArrow.tsx b/app/components/ScrollUpArrow.tsx new file mode 100644 index 0000000..f923ad9 --- /dev/null +++ b/app/components/ScrollUpArrow.tsx @@ -0,0 +1,43 @@ +'use client'; +import { useEffect, useState } from 'react'; + +const ScrollToTop = () => { + const [isVisible, setIsVisible] = useState(false); + + const toggleVisibility = () => { + if (window.scrollY > 300) { + setIsVisible(true); + } else { + setIsVisible(false); + } + }; + + const scrollToTop = () => { + window.scrollTo({ + top: 0, + behavior: 'smooth', + }); + }; + + useEffect(() => { + window.addEventListener('scroll', toggleVisibility); + return () => { + window.removeEventListener('scroll', toggleVisibility); + }; + }, []); + + return ( +