@@ -16,15 +16,43 @@ const styles = StyleSheet.create({
16
16
} ) ;
17
17
18
18
type Props < T > = FlatListProps < T > & {
19
+ /**
20
+ * Called once when the scroll position gets close to end of list. This must return a promise.
21
+ * You can `onEndReachedThreshold` as distance from end of list, when this function should be called.
22
+ */
19
23
onEndReached : ( ) => Promise < void > ;
24
+ /**
25
+ * Called once when the scroll position gets close to begining of list. This must return a promise.
26
+ * You can `onStartReachedThreshold` as distance from beginning of list, when this function should be called.
27
+ */
20
28
onStartReached : ( ) => Promise < void > ;
29
+ /** Color or inline loading indicator */
21
30
activityIndicatorColor ?: string ;
31
+ /**
32
+ * Enable autoScrollToTop.
33
+ * In chat type applications, you want to auto scroll to bottom, when new message comes it.
34
+ */
35
+ enableAutoscrollToTop ?: boolean ;
36
+ /**
37
+ * If `enableAutoscrollToTop` is true, the scroll threshold below which auto scrolling should occur.
38
+ */
39
+ autoscrollToTopThreshold ?: number ;
40
+ /** Scroll distance from beginning of list, when onStartReached should be called. */
22
41
onStartReachedThreshold ?: number ;
42
+ /**
43
+ * Scroll distance from end of list, when onStartReached should be called.
44
+ * Please note that this is different from onEndReachedThreshold of FlatList from react-native.
45
+ */
23
46
onEndReachedThreshold ?: number ;
47
+ /** If true, inline loading indicators will be shown. Default - true */
24
48
showDefaultLoadingIndicators ?: boolean ;
49
+ /** Custom UI component for header inline loading indicator */
25
50
HeaderLoadingIndicator ?: React . ComponentType ;
51
+ /** Custom UI component for footer inline loading indicator */
26
52
FooterLoadingIndicator ?: React . ComponentType ;
53
+ /** Custom UI component for header indicator of FlatList. Only used when `showDefaultLoadingIndicators` is false */
27
54
ListHeaderComponent ?: React . ComponentType ;
55
+ /** Custom UI component for footer indicator of FlatList. Only used when `showDefaultLoadingIndicators` is false */
28
56
ListFooterComponent ?: React . ComponentType ;
29
57
} ;
30
58
@@ -42,6 +70,8 @@ const BidirectionalFlatList = <T extends any>(props: Props<T>) => {
42
70
const {
43
71
activityIndicatorColor = 'black' ,
44
72
data,
73
+ enableAutoscrollToTop,
74
+ autoscrollToTopThreshold = 100 ,
45
75
FooterLoadingIndicator,
46
76
HeaderLoadingIndicator,
47
77
ListHeaderComponent,
@@ -198,7 +228,9 @@ const BidirectionalFlatList = <T extends any>(props: Props<T>) => {
198
228
onScroll = { handleScroll }
199
229
// @ts -ignore
200
230
maintainVisibleContentPosition = { {
201
- autoscrollToTopThreshold : undefined ,
231
+ autoscrollToTopThreshold : enableAutoscrollToTop
232
+ ? autoscrollToTopThreshold
233
+ : undefined ,
202
234
minIndexForVisible : 1 ,
203
235
} }
204
236
/>
0 commit comments