mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Update ASCellNode visibility API
This commit is contained in:
@@ -542,8 +542,11 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
||||
if (cellNode.neverShowPlaceholders) {
|
||||
[cellNode recursivelyEnsureDisplaySynchronously:YES];
|
||||
}
|
||||
if (ASSubclassOverridesSelector([ASCellNode class], [cellNode class], @selector(visibleNodeDidScroll:withCellFrame:))) {
|
||||
if (ASSubclassOverridesSelector([ASCellNode class], [cellNode class], @selector(cellNodeVisibilityEvent:inScrollView:withCellFrame:))) {
|
||||
[_cellsForVisibilityUpdates addObject:cell];
|
||||
[cellNode cellNodeVisibilityEvent:ASCellNodeVisibilityEventVisible
|
||||
inScrollView:collectionView
|
||||
withCellFrame:cell.frame];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -556,8 +559,14 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
||||
ASDisplayNodeAssertNotNil(node, @"Expected node associated with removed cell not to be nil.");
|
||||
[_asyncDelegate collectionView:self didEndDisplayingNode:node forItemAtIndexPath:indexPath];
|
||||
}
|
||||
[_cellsForVisibilityUpdates removeObject:cell];
|
||||
|
||||
|
||||
if ([_cellsForVisibilityUpdates containsObject:cell]) {
|
||||
ASCellNode *node = ((_ASCollectionViewCell *)cell).node;
|
||||
[node cellNodeVisibilityEvent:ASCellNodeVisibilityEventInvisible
|
||||
inScrollView:collectionView
|
||||
withCellFrame:cell.frame];
|
||||
[_cellsForVisibilityUpdates removeObject:cell];
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
@@ -681,9 +690,10 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
||||
{
|
||||
for (_ASCollectionViewCell *collectionCell in _cellsForVisibilityUpdates) {
|
||||
ASCellNode *node = [collectionCell node];
|
||||
// Only nodes that respond to the selector are added to _cellsForVisibilityUpdates
|
||||
[node visibleNodeDidScroll:scrollView withCellFrame:collectionCell.frame];
|
||||
[[collectionCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventVisibleRectChanged
|
||||
inScrollView:scrollView
|
||||
withCellFrame:collectionCell.frame];
|
||||
}
|
||||
if (_asyncDelegateImplementsScrollviewDidScroll) {
|
||||
[_asyncDelegate scrollViewDidScroll:scrollView];
|
||||
|
||||
Reference in New Issue
Block a user