@@ -16,15 +16,43 @@ const styles = StyleSheet.create({
1616} ) ;
1717
1818type 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+ */
1923 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+ */
2028 onStartReached : ( ) => Promise < void > ;
29+ /** Color or inline loading indicator */
2130 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. */
2241 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+ */
2346 onEndReachedThreshold ?: number ;
47+ /** If true, inline loading indicators will be shown. Default - true */
2448 showDefaultLoadingIndicators ?: boolean ;
49+ /** Custom UI component for header inline loading indicator */
2550 HeaderLoadingIndicator ?: React . ComponentType ;
51+ /** Custom UI component for footer inline loading indicator */
2652 FooterLoadingIndicator ?: React . ComponentType ;
53+ /** Custom UI component for header indicator of FlatList. Only used when `showDefaultLoadingIndicators` is false */
2754 ListHeaderComponent ?: React . ComponentType ;
55+ /** Custom UI component for footer indicator of FlatList. Only used when `showDefaultLoadingIndicators` is false */
2856 ListFooterComponent ?: React . ComponentType ;
2957} ;
3058
@@ -42,6 +70,8 @@ const BidirectionalFlatList = <T extends any>(props: Props<T>) => {
4270 const {
4371 activityIndicatorColor = 'black' ,
4472 data,
73+ enableAutoscrollToTop,
74+ autoscrollToTopThreshold = 100 ,
4575 FooterLoadingIndicator,
4676 HeaderLoadingIndicator,
4777 ListHeaderComponent,
@@ -198,7 +228,9 @@ const BidirectionalFlatList = <T extends any>(props: Props<T>) => {
198228 onScroll = { handleScroll }
199229 // @ts -ignore
200230 maintainVisibleContentPosition = { {
201- autoscrollToTopThreshold : undefined ,
231+ autoscrollToTopThreshold : enableAutoscrollToTop
232+ ? autoscrollToTopThreshold
233+ : undefined ,
202234 minIndexForVisible : 1 ,
203235 } }
204236 />
0 commit comments