From 4971d15acb24661cb624379f27cda2ca3e45da19 Mon Sep 17 00:00:00 2001 From: Maxence Coulibaly Date: Tue, 16 Apr 2024 09:33:40 +0400 Subject: [PATCH] Merge pull request #40201 from suneox/40076-update-adjust-viewport 40076 update adjust viewport (cherry picked from commit eef5fde8536c78726dcbcf1632839b803b7d8526) --- src/hooks/useViewportOffsetTop/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/useViewportOffsetTop/index.ts b/src/hooks/useViewportOffsetTop/index.ts index da2325a7e13f..6f617aa38121 100644 --- a/src/hooks/useViewportOffsetTop/index.ts +++ b/src/hooks/useViewportOffsetTop/index.ts @@ -18,7 +18,7 @@ export default function useViewportOffsetTop(shouldAdjustScrollView = false): nu if (Browser.isMobileSafari() && shouldAdjustScrollView && window.visualViewport) { const clientHeight = document.body.clientHeight; - const adjustScrollY = Math.round(clientHeight - window.visualViewport.height); + const adjustScrollY = clientHeight - window.visualViewport.height; if (cachedDefaultOffsetTop.current === 0) { cachedDefaultOffsetTop.current = targetOffsetTop; } @@ -43,7 +43,7 @@ export default function useViewportOffsetTop(shouldAdjustScrollView = false): nu if (!shouldAdjustScrollView) { return; } - window.scrollTo({top: viewportOffsetTop, behavior: 'instant'}); + window.scrollTo({top: viewportOffsetTop, behavior: 'smooth'}); }, [shouldAdjustScrollView, viewportOffsetTop]); return viewportOffsetTop;