-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow providing an external scrollview. #502
Changes from 4 commits
c2d4fae
0d552c5
939ebbf
3d8d137
9401507
78e686e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,14 @@ estimatedItemSize?: number; | |
|
||
--- | ||
|
||
### `renderScrollComponent` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Props are sorted alphabetically. Moving this would be helpful. |
||
|
||
Rendered as the main scrollview. Its contract for the scroll event should match the native scroll event contract, i.e. `scrollEvent = { nativeEvent: { contentOffset: { x: offset, y: offset } } }` | ||
|
||
```ts | ||
return <FlashList renderScrollComponent={Animated.ScrollView} />; | ||
``` | ||
|
||
### `CellRendererComponent` | ||
|
||
Each cell is rendered using this element. Can be a React Component Class, or a render function. The root component should always be a `CellContainer` which is also the default component used. Ensure that the original `props` are passed to the returned `CellContainer`. The `props` contain the following properties: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -276,6 +276,7 @@ class FlashList<T> extends React.PureComponent< | |
initialScrollIndex, | ||
style, | ||
contentContainerStyle, | ||
renderScrollComponent, | ||
...restProps | ||
} = this.props; | ||
|
||
|
@@ -350,6 +351,7 @@ class FlashList<T> extends React.PureComponent< | |
windowCorrectionConfig={this.getUpdatedWindowCorrectionConfig()} | ||
itemAnimator={this.itemAnimator} | ||
suppressBoundedSizeException | ||
externalScrollView={renderScrollComponent as any} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typecast to BaseScrollView instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i had to cast it to externalScrollView?: {
new (props: ScrollViewDefaultProps): BaseScrollView;
}; |
||
/> | ||
</StickyHeaderContainer> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import type React from "react"; | ||
import { | ||
StyleProp, | ||
ScrollViewProps, | ||
|
@@ -6,6 +7,7 @@ import { | |
ViewStyle, | ||
ColorValue, | ||
} from "react-native"; | ||
import type { ScrollViewDefaultProps } from "recyclerlistview/dist/reactnative/core/scrollcomponent/BaseScrollView"; | ||
|
||
import { BlankAreaEventHandler } from "./native/auto-layout/AutoLayoutView"; | ||
import ViewToken from "./viewability/ViewToken"; | ||
|
@@ -122,6 +124,14 @@ export interface FlashListProps<TItem> extends ScrollViewProps { | |
*/ | ||
ListHeaderComponentStyle?: StyleProp<ViewStyle> | undefined; | ||
|
||
/** | ||
* Rendered as the main scrollview. Its contract for the scroll event should match the native scroll event contract, i.e. | ||
* `scrollEvent = { nativeEvent: { contentOffset: { x: offset, y: offset } } }` | ||
*/ | ||
renderScrollComponent?: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's use default scroll view props from RN. That should be fine. All this complexity in RLV is due to its web only implementation. FlashList doesn't depend on it so using ScrollView props should be fine. |
||
| React.ComponentType<ScrollViewDefaultProps> | ||
| React.FC<ScrollViewDefaultProps>; | ||
|
||
/** | ||
* You can use `contentContainerStyle` to apply padding that will be applied to the whole content itself. | ||
* For example, you can apply this padding, so that all of your items have leading and trailing space. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add link to this PR here