about summary refs log tree commit diff
path: root/src/lib/hooks
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-05-25 00:10:48 -0500
committerPaul Frazee <pfrazee@gmail.com>2023-05-25 00:10:48 -0500
commit0262ed11ea95269c80598c5150e49978a027ee0b (patch)
treefae0bbca7368a7721d8eed61938c33aba4e2b169 /src/lib/hooks
parent5124be33ade7565850e7bcc557192f1f51c17801 (diff)
downloadvoidsky-0262ed11ea95269c80598c5150e49978a027ee0b.tar.zst
Fix the 'dancing header' problem on web
Diffstat (limited to 'src/lib/hooks')
-rw-r--r--src/lib/hooks/useOnMainScroll.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lib/hooks/useOnMainScroll.ts b/src/lib/hooks/useOnMainScroll.ts
index 782c4704b..12e42aca5 100644
--- a/src/lib/hooks/useOnMainScroll.ts
+++ b/src/lib/hooks/useOnMainScroll.ts
@@ -2,6 +2,9 @@ import {useState, useCallback, useRef} from 'react'
 import {NativeSyntheticEvent, NativeScrollEvent} from 'react-native'
 import {RootStoreModel} from 'state/index'
 import {s} from 'lib/styles'
+import {isDesktopWeb} from 'platform/detection'
+
+const DY_LIMIT = isDesktopWeb ? 30 : 10
 
 export type OnScrollCb = (
   event: NativeSyntheticEvent<NativeScrollEvent>,
@@ -20,9 +23,12 @@ export function useOnMainScroll(
         const dy = y - (lastY.current || 0)
         lastY.current = y
 
-        if (!store.shell.minimalShellMode && y > 10 && dy > 10) {
+        if (!store.shell.minimalShellMode && y > 10 && dy > DY_LIMIT) {
           store.shell.setMinimalShellMode(true)
-        } else if (store.shell.minimalShellMode && (y <= 10 || dy < -10)) {
+        } else if (
+          store.shell.minimalShellMode &&
+          (y <= 10 || dy < DY_LIMIT * -1)
+        ) {
           store.shell.setMinimalShellMode(false)
         }