Nested virtualized lists should receive recordInteration events
Summary: Right now when an interaction is recorded on a parent VirtualizedList, the interaction isn't passed on to its children. That means that if `waitForInteraction` is set to true for a child list's viewability helper, it will never trigger a VPV. This change adds forwarding of these events inside `onBeginScrollDrag`. It also forwards the interaction state of the parent list at register time, in case a child list is rendered mid-scroll. Reviewed By: sahrens Differential Revision: D6822091 fbshipit-source-id: dfe300e42722d4285f65787ab2c1368f050c5577
This commit is contained in:
parent
ecaca80d42
commit
ae2d5b1e68
|
@ -375,6 +375,9 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|||
}
|
||||
|
||||
recordInteraction() {
|
||||
this._nestedChildLists.forEach(childList => {
|
||||
childList.ref && childList.ref.recordInteraction();
|
||||
});
|
||||
this._viewabilityTuples.forEach(t => {
|
||||
t.viewabilityHelper.recordInteraction();
|
||||
});
|
||||
|
@ -512,6 +515,10 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|||
state: null,
|
||||
});
|
||||
|
||||
if (this._hasInteracted) {
|
||||
childList.ref.recordInteraction();
|
||||
}
|
||||
|
||||
return existingChildData && existingChildData.state;
|
||||
};
|
||||
|
||||
|
@ -941,6 +948,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|||
_frames = {};
|
||||
_footerLength = 0;
|
||||
_hasDataChangedSinceEndReached = true;
|
||||
_hasInteracted = false;
|
||||
_hasMore = false;
|
||||
_hasWarned = {};
|
||||
_highestMeasuredFrameIndex = 0;
|
||||
|
@ -1334,9 +1342,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|||
}
|
||||
|
||||
_onScrollBeginDrag = (e): void => {
|
||||
this._nestedChildLists.forEach(childList => {
|
||||
childList.ref && childList.ref._onScrollBeginDrag(e);
|
||||
});
|
||||
this._viewabilityTuples.forEach(tuple => {
|
||||
tuple.viewabilityHelper.recordInteraction();
|
||||
});
|
||||
this._hasInteracted = true;
|
||||
this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue