about summary refs log tree commit diff
path: root/src/view/com/util/MainScrollProvider.tsx
diff options
context:
space:
mode:
authorJan-Olof Eriksson <jan-olof.eriksson@iki.fi>2024-02-29 11:55:03 +0200
committerGitHub <noreply@github.com>2024-02-29 11:55:03 +0200
commit963a44ab872a1044d6997a8fcf7b2fc754ac618a (patch)
treebbd64f464a8f14e55cbb06e28811cdc43f059d29 /src/view/com/util/MainScrollProvider.tsx
parent1f9562847512bb41cd8bb381b735a388be4db59b (diff)
parenta35976cdc9b6467ad8b6e0c4ff46ba684fee9064 (diff)
downloadvoidsky-963a44ab872a1044d6997a8fcf7b2fc754ac618a.tar.zst
Merge branch 'bluesky-social:main' into main
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 (