mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Don't pre-render cell nodes of collection view when it is not visible or not scrolling
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#import "ASCollectionView.h"
|
||||
#import "CGRect+ASConvenience.h"
|
||||
#import "UICollectionViewLayout+ASConvenience.h"
|
||||
#import "ASDisplayNodeExtras.h"
|
||||
|
||||
struct ASRangeGeometry {
|
||||
CGRect rangeBounds;
|
||||
@@ -164,4 +165,19 @@ typedef struct ASRangeGeometry ASRangeGeometry;
|
||||
return CGRectExpandToRangeWithScrollableDirections(rect, tuningParameters, _scrollableDirections, scrollDirection);
|
||||
}
|
||||
|
||||
- (ASRangeTuningParameters)tuningParametersForRangeType:(ASLayoutRangeType)rangeType
|
||||
{
|
||||
BOOL isVisible = ASInterfaceStateIncludesVisible(_collectionView.interfaceState);
|
||||
BOOL isScrolling = (_collectionView.scrollDirection != ASScrollDirectionNone);
|
||||
// When the collecion view is not visible or not scrolling, make display range only as big as visible range.
|
||||
// This reduce early creation of views and layers.
|
||||
if (!isVisible || !isScrolling) {
|
||||
if (rangeType == ASLayoutRangeTypeDisplay) {
|
||||
return [super tuningParametersForRangeType:ASLayoutRangeTypeVisible];
|
||||
}
|
||||
}
|
||||
|
||||
return [super tuningParametersForRangeType:rangeType];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user