Fix: re-add the scroll boundary to avoid minimal shell at top of screen (#956)

zio/stable
Paul Frazee 2023-07-03 18:36:49 -05:00 committed by GitHub
parent 40a872612f
commit c8eeb6ba1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import {isDesktopWeb} from 'platform/detection'
const DY_LIMIT_UP = isDesktopWeb ? 30 : 10 const DY_LIMIT_UP = isDesktopWeb ? 30 : 10
const DY_LIMIT_DOWN = isDesktopWeb ? 150 : 10 const DY_LIMIT_DOWN = isDesktopWeb ? 150 : 10
const Y_LIMIT = 10
export type OnScrollCb = ( export type OnScrollCb = (
event: NativeSyntheticEvent<NativeScrollEvent>, event: NativeSyntheticEvent<NativeScrollEvent>,
@ -24,9 +25,16 @@ export function useOnMainScroll(
const dy = y - (lastY.current || 0) const dy = y - (lastY.current || 0)
lastY.current = y lastY.current = y
if (!store.shell.minimalShellMode && dy > DY_LIMIT_DOWN) { if (
!store.shell.minimalShellMode &&
dy > DY_LIMIT_DOWN &&
y > Y_LIMIT
) {
store.shell.setMinimalShellMode(true) store.shell.setMinimalShellMode(true)
} else if (store.shell.minimalShellMode && dy < DY_LIMIT_UP * -1) { } else if (
store.shell.minimalShellMode &&
(dy < DY_LIMIT_UP * -1 || y <= Y_LIMIT)
) {
store.shell.setMinimalShellMode(false) store.shell.setMinimalShellMode(false)
} }