Skip to content

Commit

Permalink
Follow up on the ASRangeController fix in #1418
Browse files Browse the repository at this point in the history
The changes in #1418 is a bit too aggressive when it comes to nodes that are in display range. It forces those nodes to not preload.
  • Loading branch information
nguyenhuy committed Mar 22, 2019
1 parent 09365b9 commit a3a1e96
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions Source/Details/ASRangeController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -351,24 +351,27 @@ - (void)_updateVisibleNodeIndexPaths
} else {
// If selfInterfaceState isn't visible, then visibleIndexPaths represents either what /will/ be immediately visible at the
// instant we come onscreen, or what /will/ no longer be visible at the instant we come offscreen.
// So, preload and display all of those things, but don't waste resources preloading others.
// We handle this as a separate case to minimize set operations, including -containsObject:.
// So, preload and display all of those things, but don't waste resources displaying others.
//
// DO NOT set Visible: even though these elements are in the visible range / "viewport",
// our overall container object is itself not yet, or no longer, visible.
// The moment it becomes visible, we will run the condition above.

BOOL shouldUpdateInterfaceState = NO;
if (ASActivateExperimentalFeature(ASExperimentalFixRangeController)) {
shouldUpdateInterfaceState = [visibleIndexPaths containsObject:indexPath];
if ([visibleIndexPaths containsObject:indexPath]) {
interfaceState |= ASInterfaceStatePreload;
if (rangeMode != ASLayoutRangeModeLowMemory) {
interfaceState |= ASInterfaceStateDisplay;
}
} else if ([displayIndexPaths containsObject:indexPath]) {
interfaceState |= ASInterfaceStatePreload;
}
} else {
shouldUpdateInterfaceState = [allCurrentIndexPaths containsObject:indexPath];
}

if (shouldUpdateInterfaceState) {
interfaceState |= ASInterfaceStatePreload;
if (rangeMode != ASLayoutRangeModeLowMemory) {
interfaceState |= ASInterfaceStateDisplay;
if ([allCurrentIndexPaths containsObject:indexPath]) {
interfaceState |= ASInterfaceStatePreload;
if (rangeMode != ASLayoutRangeModeLowMemory) {
interfaceState |= ASInterfaceStateDisplay;
}
}
}
}
Expand Down

0 comments on commit a3a1e96

Please sign in to comment.