Fix on mobile
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import React, {useState} from 'react'
|
import React, {useState} from 'react'
|
||||||
import {FlatListProps} from 'react-native'
|
import {FlatListProps} from 'react-native'
|
||||||
import {FlatList_INTERNAL} from './Views'
|
import {FlatList_INTERNAL} from './Views'
|
||||||
|
import {runOnJS} from 'react-native-reanimated'
|
||||||
import {useAnimatedScrollHandler} from '#/lib/hooks/useAnimatedScrollHandler_FIXED'
|
import {useAnimatedScrollHandler} from '#/lib/hooks/useAnimatedScrollHandler_FIXED'
|
||||||
|
|
||||||
export type ListMethods = FlatList_INTERNAL
|
export type ListMethods = FlatList_INTERNAL
|
||||||
@@ -17,13 +18,17 @@ function ListImpl<ItemT>(
|
|||||||
) {
|
) {
|
||||||
const [isScrolledDown, setIsScrolledDown] = useState(false)
|
const [isScrolledDown, setIsScrolledDown] = useState(false)
|
||||||
|
|
||||||
|
function handleScrolledDownChange(didScrollDown: boolean) {
|
||||||
|
setIsScrolledDown(didScrollDown)
|
||||||
|
onScrolledDownChange?.(didScrollDown)
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: This ignores the passed-in onScroll completely.
|
// TODO: This ignores the passed-in onScroll completely.
|
||||||
const scrollHandler = useAnimatedScrollHandler({
|
const scrollHandler = useAnimatedScrollHandler({
|
||||||
onScroll(e) {
|
onScroll(e) {
|
||||||
const didScrollDown = e.contentOffset.y > SCROLLED_DOWN_LIMIT
|
const didScrollDown = e.contentOffset.y > SCROLLED_DOWN_LIMIT
|
||||||
if (isScrolledDown !== didScrollDown) {
|
if (isScrolledDown !== didScrollDown) {
|
||||||
setIsScrolledDown(didScrollDown)
|
runOnJS(handleScrolledDownChange)(didScrollDown)
|
||||||
onScrolledDownChange?.(didScrollDown)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user