Skip to content
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

Plv render after first draw #688

Merged
merged 2 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "recyclerlistview",
"version": "3.1.0-beta.3",
"version": "3.1.0-beta.4",
"description": "The listview that you need and deserve. It was built for performance, uses cell recycling to achieve smooth scrolling.",
"main": "dist/reactnative/index.js",
"types": "dist/reactnative/index.d.ts",
Expand Down
17 changes: 14 additions & 3 deletions src/core/ProgressiveListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,23 @@ export default class ProgressiveListView extends RecyclerListView<ProgressiveLis
renderAheadOffset: 0,
};
private renderAheadUdpateCallbackId?: number;
private isFirstLayoutComplete: boolean = false;

public componentDidMount(): void {
if (super.componentDidMount) {
super.componentDidMount();
super.componentDidMount();
if (!this.props.forceNonDeterministicRendering) {
this.updateRenderAheadProgessively(this.getCurrentRenderAheadOffset());
}
this.updateRenderAheadProgessively(this.getCurrentRenderAheadOffset());
}

protected onItemLayout(index: number): void {
if (!this.isFirstLayoutComplete) {
this.isFirstLayoutComplete = true;
if (this.props.forceNonDeterministicRendering) {
this.updateRenderAheadProgessively(this.getCurrentRenderAheadOffset());
}
}
super.onItemLayout(index);
}

private updateRenderAheadProgessively(newVal: number): void {
Expand Down
12 changes: 11 additions & 1 deletion src/core/RecyclerListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,15 @@ export default class RecyclerListView<P extends RecyclerListViewProps, S extends
protected getVirtualRenderer(): VirtualRenderer {
return this._virtualRenderer;
}
protected onItemLayout(index: number): void {
if (this.props.onItemLayout) {
this.props.onItemLayout(index);
}
}

private _onItemLayout = (index: number) => {
this.onItemLayout(index);
}

private _processInitialOffset(): void {
if (this._pendingScrollToOffset) {
Expand Down Expand Up @@ -630,7 +639,7 @@ export default class RecyclerListView<P extends RecyclerListViewProps, S extends
extendedState={this.props.extendedState}
internalSnapshot={this.state.internalSnapshot}
renderItemContainer={this.props.renderItemContainer}
onItemLayout={this.props.onItemLayout}/>
onItemLayout={this._onItemLayout}/>
);
}
return null;
Expand Down Expand Up @@ -829,5 +838,6 @@ RecyclerListView.propTypes = {
// This can be used to hook an itemLayoutListener to listen to which item at what index is layout.
// To get the layout params of the item, you can use the ref to call method getLayout(index), e.x. : `this._recyclerRef.getLayout(index)`
// but there is a catch here, since there might be a pending relayout due to which the queried layout might not be precise.
// Caution: RLV only listens to layout changes if forceNonDeterministicRendering is true
onItemLayout: PropTypes.func,
};