Skip to content

Commit

Permalink
40076 update adjust scrollY on visual viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
suneox committed Apr 13, 2024
1 parent db9e01c commit 021d945
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hooks/useViewportOffsetTop/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit 021d945

Please sign in to comment.