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

fix onItemLayout #717

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 8 additions & 3 deletions src/platform/reactnative/viewrenderer/ViewRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class ViewRenderer extends BaseViewRenderer<any> {
}
: {
ref: this._setRef,
onLayout: this._onItemLayout,
style: {
left: this.props.x,
position: "absolute",
Expand Down Expand Up @@ -75,6 +76,12 @@ export default class ViewRenderer extends BaseViewRenderer<any> {
this._viewRef = view;
}

private _onItemLayout = (): void => {
if (this.props.onItemLayout) {
this.props.onItemLayout(this.props.index);
}
}

private _onLayout = (event: LayoutChangeEvent): void => {
//Preventing layout thrashing in super fast scrolls where RN messes up onLayout event
const xDiff = Math.abs(this.props.x - event.nativeEvent.layout.x);
Expand All @@ -89,9 +96,7 @@ export default class ViewRenderer extends BaseViewRenderer<any> {
}
}

if (this.props.onItemLayout) {
this.props.onItemLayout(this.props.index);
}
this._onItemLayout();
}
private _forceSizeUpdate = (dim: Dimension): void => {
if (dim.width === this._dim.width && dim.height === this._dim.height) {
Expand Down