Fix the 'dancing header' problem on web
parent
5124be33ad
commit
0262ed11ea
|
@ -2,6 +2,9 @@ import {useState, useCallback, useRef} from 'react'
|
||||||
import {NativeSyntheticEvent, NativeScrollEvent} from 'react-native'
|
import {NativeSyntheticEvent, NativeScrollEvent} from 'react-native'
|
||||||
import {RootStoreModel} from 'state/index'
|
import {RootStoreModel} from 'state/index'
|
||||||
import {s} from 'lib/styles'
|
import {s} from 'lib/styles'
|
||||||
|
import {isDesktopWeb} from 'platform/detection'
|
||||||
|
|
||||||
|
const DY_LIMIT = isDesktopWeb ? 30 : 10
|
||||||
|
|
||||||
export type OnScrollCb = (
|
export type OnScrollCb = (
|
||||||
event: NativeSyntheticEvent<NativeScrollEvent>,
|
event: NativeSyntheticEvent<NativeScrollEvent>,
|
||||||
|
@ -20,9 +23,12 @@ 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 && y > 10 && dy > 10) {
|
if (!store.shell.minimalShellMode && y > 10 && dy > DY_LIMIT) {
|
||||||
store.shell.setMinimalShellMode(true)
|
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)
|
store.shell.setMinimalShellMode(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue