Skip to content
Permalink
Browse files

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
  • Loading branch information...
Logan Daniels authored and facebook-github-bot committed Jan 29, 2018
1 parent ecaca80 commit ae2d5b1e68a2207c27ef2f1b533f86c86d6d849b
Showing with 12 additions and 0 deletions.
  1. +12 −0 Libraries/Lists/VirtualizedList.js
@@ -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);
};

0 comments on commit ae2d5b1

Please sign in to comment.
You can’t perform that action at this time.