From 122b63d53377ac7cac21d982f7c6c32bf69330d6 Mon Sep 17 00:00:00 2001 From: xomimishka Date: Tue, 8 Jul 2025 01:21:54 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=BC=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20=D1=81=D0=BA=D1=80=D0=BE=D0=BB=D0=BB=D0=B0=20=D0=B2?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/Layout/Root.tsx | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/app/Layout/Root.tsx b/src/app/Layout/Root.tsx index 42ce703..87ad5f3 100644 --- a/src/app/Layout/Root.tsx +++ b/src/app/Layout/Root.tsx @@ -60,14 +60,28 @@ function Root() { }; }, [hasScrolled]); - // Ускоренный плавный скролл вверх + // скролл вверх const scrollToTop = () => { - window.scrollTo({ - top: 0, - behavior: "smooth", - }); + const duration = 900; + const start = window.scrollY; + const startTime = performance.now(); + + const animateScroll = (currentTime: number) => { + const timeElapsed = currentTime - startTime; + const progress = Math.min(timeElapsed / duration, 1); + const ease = 1 - Math.pow(1 - progress, 3); + + window.scrollTo(0, start * (1 - ease)); + + if (timeElapsed < duration) { + requestAnimationFrame(animateScroll); + } }; + requestAnimationFrame(animateScroll); +}; + + // Определяем, находимся ли мы на главной странице const isHomePage = location.pathname === "/";