Update for visibility monitoring

This commit is contained in:
Max Gu
2016-02-19 14:27:22 -08:00
parent 274029a5e0
commit a834382bcb
3 changed files with 9 additions and 7 deletions

View File

@@ -10,6 +10,6 @@
@interface ASCellNode (Internal)
@property (nonatomic, assign) BOOL shouldObserveVisibility;
@property (nonatomic, assign) BOOL shouldMonitorScrollViewDidScroll;
@end

View File

@@ -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];
}
}

View File

@@ -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) {