From a834382bcbc521f236d96689d6c6644a4df903fc Mon Sep 17 00:00:00 2001 From: Max Gu Date: Fri, 19 Feb 2016 14:27:22 -0800 Subject: [PATCH] Update for visibility monitoring --- AsyncDisplayKit/ASCellNode+Internal.h | 2 +- AsyncDisplayKit/ASCellNode.m | 6 +++--- AsyncDisplayKit/ASCollectionView.mm | 8 +++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/AsyncDisplayKit/ASCellNode+Internal.h b/AsyncDisplayKit/ASCellNode+Internal.h index feb816467d..5481965995 100644 --- a/AsyncDisplayKit/ASCellNode+Internal.h +++ b/AsyncDisplayKit/ASCellNode+Internal.h @@ -10,6 +10,6 @@ @interface ASCellNode (Internal) -@property (nonatomic, assign) BOOL shouldObserveVisibility; +@property (nonatomic, assign) BOOL shouldMonitorScrollViewDidScroll; @end diff --git a/AsyncDisplayKit/ASCellNode.m b/AsyncDisplayKit/ASCellNode.m index 61458d5ac0..42f5b0b971 100644 --- a/AsyncDisplayKit/ASCellNode.m +++ b/AsyncDisplayKit/ASCellNode.m @@ -38,7 +38,7 @@ _selectionStyle = UITableViewCellSelectionStyleDefault; self.clipsToBounds = YES; if ([self.layoutDelegate respondsToSelector:@selector(visibleNodeDidScroll:inScrollView:withCellFrame:)]) { - self.shouldObserveVisibility= YES; + self.shouldMonitorScrollViewDidScroll = YES; } return self; } @@ -61,7 +61,7 @@ } if ([self.layoutDelegate respondsToSelector:@selector(visibleNodeDidScroll:inScrollView:withCellFrame:)]) { - self.shouldObserveVisibility = YES; + self.shouldMonitorScrollViewDidScroll = YES; } return self; } @@ -142,7 +142,7 @@ - (void)_visibleNodeDidScroll:(UIScrollView *)scrollView withCellFrame:(CGRect)cellFrame { - if (self.shouldObserveVisibility) { + if (self.shouldMonitorScrollViewDidScroll) { [self.layoutDelegate visibleNodeDidScroll:self inScrollView:scrollView withCellFrame:cellFrame]; } } diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index 1f9a7ff89b..35ddd61c22 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -673,9 +673,11 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; - (void)scrollViewDidScroll:(UIScrollView *)scrollView { - for (ASCellNode *node in _cellsForVisibilityUpdates) { - if (node.shouldObserveVisibility) { - [node _visibleNodeDidScroll:scrollView withCellFrame:node.frame]; + for (_ASCollectionViewCell *collectionCell in _cellsForVisibilityUpdates) { + ASCellNode *node = [collectionCell node]; + if (node.shouldMonitorScrollViewDidScroll) { + NSLog(@"Calling _visibleNodeDidScroll"); + [node _visibleNodeDidScroll:scrollView withCellFrame: node.frame]; } } if (_asyncDelegateImplementsScrollviewDidScroll) {