about summary refs log tree commit diff
path: root/src/view/com/util/MainScrollProvider.tsx
diff options
context:
space:
mode:
authorMinseo Lee <itoupluk427@gmail.com>2024-02-28 13:03:55 +0900
committerGitHub <noreply@github.com>2024-02-28 13:03:55 +0900
commit3767e763906088d410da9ca99532c093368ca196 (patch)
tree533df6df19320459b69c54c7b26fac5b59279e5e /src/view/com/util/MainScrollProvider.tsx
parent41e69651f97cc95d42ff4ae247706604faca51ae (diff)
parentc4d30a0b7fb3e73b208a01d0f62130535d549392 (diff)
downloadvoidsky-3767e763906088d410da9ca99532c093368ca196.tar.zst
Merge branch 'bluesky-social:main' into patch-3
Diffstat (limited to 'src/view/com/util/MainScrollProvider.tsx')
-rw-r--r--src/view/com/util/MainScrollProvider.tsx16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/view/com/util/MainScrollProvider.tsx b/src/view/com/util/MainScrollProvider.tsx
index 2c90e33ff..01b8a954d 100644
--- a/src/view/com/util/MainScrollProvider.tsx
+++ b/src/view/com/util/MainScrollProvider.tsx
@@ -20,12 +20,14 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) {
   const setMode = useSetMinimalShellMode()
   const startDragOffset = useSharedValue<number | null>(null)
   const startMode = useSharedValue<number | null>(null)
+  const didJustRestoreScroll = useSharedValue<boolean>(false)
 
   useEffect(() => {
     if (isWeb) {
       return listenToForcedWindowScroll(() => {
         startDragOffset.value = null
         startMode.value = null
+        didJustRestoreScroll.value = true
       })
     }
   })
@@ -86,6 +88,11 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) {
           mode.value = newValue
         }
       } else {
+        if (didJustRestoreScroll.value) {
+          didJustRestoreScroll.value = false
+          // Don't hide/show navbar based on scroll restoratoin.
+          return
+        }
         // On the web, we don't try to follow the drag because we don't know when it ends.
         // Instead, show/hide immediately based on whether we're scrolling up or down.
         const dy = e.contentOffset.y - (startDragOffset.value ?? 0)
@@ -98,7 +105,14 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) {
         }
       }
     },
-    [headerHeight, mode, setMode, startDragOffset, startMode],
+    [
+      headerHeight,
+      mode,
+      setMode,
+      startDragOffset,
+      startMode,
+      didJustRestoreScroll,
+    ],
   )
 
   return (