@@ -12,6 +12,7 @@ import {
1212} from 'react-native-reanimated' ;
1313import { useDebouncedCallback } from 'use-debounce' ;
1414import type { SharedScrollContainerProps } from './types' ;
15+ import { useSafeAreaInsets } from 'react-native-safe-area-context' ;
1516
1617/**
1718 * The arguments for the useScrollContainerLogic hook.
@@ -77,6 +78,12 @@ interface UseScrollContainerLogicArgs {
7778 * ensure that this function is a [worklet](https://docs.swmansion.com/react-native-reanimated/docs/2.x/fundamentals/worklets/).
7879 */
7980 onScrollWorklet ?: ( evt : NativeScrollEvent ) => void ;
81+ /**
82+ * Whether or not the scroll container is a FlashList. This is used because FlashList actually
83+ * implements the inverted property differently and requires a different approach to compute the
84+ * scroll indicator insets and content container style.
85+ */
86+ isFlashList ?: boolean ;
8087}
8188
8289/**
@@ -96,7 +103,9 @@ export const useScrollContainerLogic = ({
96103 headerFadeInThreshold = 1 ,
97104 inverted,
98105 onScrollWorklet,
106+ isFlashList = false ,
99107} : UseScrollContainerLogicArgs ) => {
108+ const insets = useSafeAreaInsets ( ) ;
100109 const [ absoluteHeaderHeight , setAbsoluteHeaderHeight ] = useState ( initialAbsoluteHeaderHeight ) ;
101110 const scrollY = useSharedValue ( 0 ) ;
102111 const largeHeaderHeight = useSharedValue ( 0 ) ;
@@ -162,6 +171,19 @@ export const useScrollContainerLogic = ({
162171 ) ;
163172
164173 const scrollViewAdjustments = useMemo ( ( ) => {
174+ if ( isFlashList ) {
175+ return {
176+ scrollIndicatorInsets : {
177+ top : absoluteHeader && inverted ? absoluteHeaderHeight : 0 ,
178+ bottom : insets . bottom ,
179+ } ,
180+ contentContainerStyle : {
181+ paddingTop : absoluteHeader && inverted ? absoluteHeaderHeight : 0 ,
182+ paddingBottom : insets . bottom ,
183+ } ,
184+ } ;
185+ }
186+
165187 return {
166188 scrollIndicatorInsets : {
167189 top : absoluteHeader && ! inverted ? absoluteHeaderHeight : 0 ,
@@ -172,7 +194,7 @@ export const useScrollContainerLogic = ({
172194 paddingBottom : absoluteHeader && inverted ? absoluteHeaderHeight : 0 ,
173195 } ,
174196 } ;
175- } , [ inverted , absoluteHeaderHeight , absoluteHeader ] ) ;
197+ } , [ inverted , absoluteHeaderHeight , absoluteHeader , isFlashList , insets ] ) ;
176198
177199 return {
178200 scrollY,
0 commit comments