diff --git a/webmasterlog/src/components/shared/ScrollToTop.tsx b/webmasterlog/src/components/shared/ScrollToTop.tsx index 09ead92e..be21bb1f 100644 --- a/webmasterlog/src/components/shared/ScrollToTop.tsx +++ b/webmasterlog/src/components/shared/ScrollToTop.tsx @@ -14,11 +14,13 @@ const ScrollToTop = () => { } }; - const scrollToTop = () => { - window.scrollTo({ - top: 0, - behavior: "smooth", - }); + const smoothScrollToTop = () => { + const scrollY = window.pageYOffset; + const scrollStep = Math.max(10, Math.floor(scrollY / 20)); + if (scrollY > 0) { + window.scrollBy(0, -scrollStep); + requestAnimationFrame(smoothScrollToTop); + } }; useEffect(() => { @@ -30,7 +32,7 @@ const ScrollToTop = () => {