Skip to content

Commit 3dda369

Browse files
authored
fix: allow for scrollIndicatorInsets to be supplied to scroll containers (#18)
1 parent 052deaf commit 3dda369

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

src/components/containers/FlashList.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const FlashListWithHeadersInputComp = <ItemT extends any = any>(
4141
automaticallyAdjustsScrollIndicatorInsets,
4242
headerFadeInThreshold = 1,
4343
disableLargeHeaderFadeAnim = false,
44+
scrollIndicatorInsets = {},
4445
...rest
4546
}: AnimatedFlashListType<ItemT>,
4647
ref: React.Ref<FlashList<ItemT>>
@@ -112,7 +113,10 @@ const FlashListWithHeadersInputComp = <ItemT extends any = any>(
112113
? automaticallyAdjustsScrollIndicatorInsets
113114
: !absoluteHeader
114115
}
115-
scrollIndicatorInsets={{ top: absoluteHeader ? absoluteHeaderHeight : 0 }}
116+
scrollIndicatorInsets={{
117+
top: absoluteHeader ? absoluteHeaderHeight : 0,
118+
...scrollIndicatorInsets,
119+
}}
116120
ListHeaderComponent={
117121
LargeHeaderComponent ? (
118122
<View

src/components/containers/FlatList.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const FlatListWithHeadersInputComp = <ItemT extends unknown>(
3737
automaticallyAdjustsScrollIndicatorInsets,
3838
headerFadeInThreshold = 1,
3939
disableLargeHeaderFadeAnim = false,
40+
scrollIndicatorInsets = {},
4041
...rest
4142
}: AnimatedFlatListProps<ItemT> & SharedScrollContainerProps,
4243
ref: React.Ref<Animated.FlatList<ItemT> | null>
@@ -107,7 +108,10 @@ const FlatListWithHeadersInputComp = <ItemT extends unknown>(
107108
? automaticallyAdjustsScrollIndicatorInsets
108109
: !absoluteHeader
109110
}
110-
scrollIndicatorInsets={{ top: absoluteHeader ? absoluteHeaderHeight : 0 }}
111+
scrollIndicatorInsets={{
112+
top: absoluteHeader ? absoluteHeaderHeight : 0,
113+
...scrollIndicatorInsets,
114+
}}
111115
ListHeaderComponent={
112116
LargeHeaderComponent ? (
113117
<View

src/components/containers/ScrollView.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { SharedScrollContainerProps } from './types';
99

1010
const AnimatedScrollView = Animated.createAnimatedComponent(ScrollView);
1111

12-
type AnimatedScrollViewProps = React.ComponentProps<typeof Animated.ScrollView> & {
12+
type AnimatedScrollViewProps = React.ComponentProps<typeof AnimatedScrollView> & {
1313
children?: React.ReactNode;
1414
};
1515

@@ -36,6 +36,7 @@ const ScrollViewWithHeadersInputComp = (
3636
contentContainerStyle,
3737
automaticallyAdjustsScrollIndicatorInsets,
3838
headerFadeInThreshold = 1,
39+
scrollIndicatorInsets = {},
3940
disableLargeHeaderFadeAnim = false,
4041
...rest
4142
}: AnimatedScrollViewProps & SharedScrollContainerProps,
@@ -97,6 +98,8 @@ const ScrollViewWithHeadersInputComp = (
9798
if (onMomentumScrollEnd) onMomentumScrollEnd(e);
9899
}}
99100
contentContainerStyle={[
101+
// @ts-ignore
102+
// Reanimated typings are causing this error - will fix in the future.
100103
contentContainerStyle,
101104
absoluteHeader ? { paddingTop: absoluteHeaderHeight } : undefined,
102105
]}
@@ -105,7 +108,10 @@ const ScrollViewWithHeadersInputComp = (
105108
? automaticallyAdjustsScrollIndicatorInsets
106109
: !absoluteHeader
107110
}
108-
scrollIndicatorInsets={{ top: absoluteHeader ? absoluteHeaderHeight : 0 }}
111+
scrollIndicatorInsets={{
112+
top: absoluteHeader ? absoluteHeaderHeight : 0,
113+
...scrollIndicatorInsets,
114+
}}
109115
{...rest}
110116
>
111117
{LargeHeaderComponent ? (

src/components/containers/SectionList.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const SectionListWithHeadersInputComp = <ItemT extends any = any, SectionT = Def
4141
automaticallyAdjustsScrollIndicatorInsets,
4242
headerFadeInThreshold = 1,
4343
disableLargeHeaderFadeAnim = false,
44+
scrollIndicatorInsets = {},
4445
...rest
4546
}: AnimatedSectionListType<ItemT, SectionT>,
4647
ref: React.Ref<Animated.ScrollView>
@@ -111,7 +112,10 @@ const SectionListWithHeadersInputComp = <ItemT extends any = any, SectionT = Def
111112
? automaticallyAdjustsScrollIndicatorInsets
112113
: !absoluteHeader
113114
}
114-
scrollIndicatorInsets={{ top: absoluteHeader ? absoluteHeaderHeight : 0 }}
115+
scrollIndicatorInsets={{
116+
top: absoluteHeader ? absoluteHeaderHeight : 0,
117+
...scrollIndicatorInsets,
118+
}}
115119
ListHeaderComponent={
116120
LargeHeaderComponent ? (
117121
<View

0 commit comments

Comments
 (0)