Go into full range mode if a scroll happens

This commit is contained in:
Michael Schneider
2016-03-12 15:44:27 -08:00
parent fe8cc9328c
commit e4ddb7e270
4 changed files with 24 additions and 1 deletions

View File

@@ -690,6 +690,8 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
- (void)scrollViewDidScroll:(UIScrollView *)scrollView - (void)scrollViewDidScroll:(UIScrollView *)scrollView
{ {
[_rangeController scrollViewDidScroll:scrollView];
for (_ASCollectionViewCell *collectionCell in _cellsForVisibilityUpdates) { for (_ASCollectionViewCell *collectionCell in _cellsForVisibilityUpdates) {
// Only nodes that respond to the selector are added to _cellsForVisibilityUpdates // Only nodes that respond to the selector are added to _cellsForVisibilityUpdates
[[collectionCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventVisibleRectChanged [[collectionCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventVisibleRectChanged

View File

@@ -602,6 +602,8 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
- (void)scrollViewDidScroll:(UIScrollView *)scrollView - (void)scrollViewDidScroll:(UIScrollView *)scrollView
{ {
[_rangeController scrollViewDidScroll:scrollView];
for (_ASTableViewCell *tableCell in _cellsForVisibilityUpdates) { for (_ASTableViewCell *tableCell in _cellsForVisibilityUpdates) {
[[tableCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventVisibleRectChanged [[tableCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventVisibleRectChanged
inScrollView:scrollView inScrollView:scrollView

View File

@@ -45,6 +45,11 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
- (void)visibleNodeIndexPathsDidChangeWithScrollDirection:(ASScrollDirection)scrollDirection; - (void)visibleNodeIndexPathsDidChangeWithScrollDirection:(ASScrollDirection)scrollDirection;
/**
* Notify the range controller that a scroll view did scroll.
*/
- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
/** /**
* Add the sized node for `indexPath` as a subview of `contentView`. * Add the sized node for `indexPath` as a subview of `contentView`.
* *

View File

@@ -61,11 +61,16 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
#pragma mark - Core visible node range managment API #pragma mark - Core visible node range managment API
+ (BOOL)isFirstRangeUpdateForRangeMode:(ASLayoutRangeMode)rangeMode
{
return (rangeMode == ASLayoutRangeModeInvalid);
}
+ (ASLayoutRangeMode)rangeModeForInterfaceState:(ASInterfaceState)interfaceState + (ASLayoutRangeMode)rangeModeForInterfaceState:(ASInterfaceState)interfaceState
currentRangeMode:(ASLayoutRangeMode)currentRangeMode currentRangeMode:(ASLayoutRangeMode)currentRangeMode
{ {
BOOL isVisible = (ASInterfaceStateIncludesVisible(interfaceState)); BOOL isVisible = (ASInterfaceStateIncludesVisible(interfaceState));
BOOL isFirstRangeUpdate = (currentRangeMode == ASLayoutRangeModeInvalid); BOOL isFirstRangeUpdate = [self isFirstRangeUpdateForRangeMode:currentRangeMode];
if (!isVisible || isFirstRangeUpdate) { if (!isVisible || isFirstRangeUpdate) {
return ASLayoutRangeModeMinimum; return ASLayoutRangeModeMinimum;
} }
@@ -94,6 +99,15 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
[self scheduleRangeUpdate]; [self scheduleRangeUpdate];
} }
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
// If a scroll happenes the current range mode needs to go to full
BOOL isFirstRangeUpdate = [[self class] isFirstRangeUpdateForRangeMode:_currentRangeMode];
if (!isFirstRangeUpdate && _currentRangeMode != ASLayoutRangeModeFull) {
[self scheduleRangeUpdate];
}
}
- (void)updateCurrentRangeWithMode:(ASLayoutRangeMode)rangeMode - (void)updateCurrentRangeWithMode:(ASLayoutRangeMode)rangeMode
{ {
if (_currentRangeMode != rangeMode) { if (_currentRangeMode != rangeMode) {