Skip to content

Commit 700905e

Browse files
Disable cache invaldation when the collection view perform an insertion of a new page to the list
Summary: See https://docs.google.com/document/d/1DRB_ZUZU15Cm0968zc7N8WmhUF4aFBhnk-GiR4ssVFQ/edit?tab=t.0 Reviewed By: matrush Differential Revision: D81792852 fbshipit-source-id: c56f652b22d6adea21629f7c950f174892a59b5e
1 parent 0944f8e commit 700905e

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

Source/IGListKit/IGListCollectionViewLayout.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ NS_SWIFT_NAME(ListCollectionViewLayout)
9797
*/
9898
@property (nonatomic, assign) BOOL showHeaderWhenEmpty;
9999

100+
/**
101+
Set this to `YES` to keep layout cache when invalidateLayout is called. Default is `NO`.
102+
*/
103+
@property (nonatomic, assign) BOOL preserveLayoutCacheOnInvalidateLayout;
104+
100105
/**
101106
Create and return a new collection view layout.
102107

Source/IGListKit/IGListCollectionViewLayout.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ - (instancetype)initWithStickyHeaders:(BOOL)stickyHeaders
204204
UICollectionElementKindSectionFooter: [NSMutableDictionary new],
205205
}];
206206
_minimumInvalidatedSection = NSNotFound;
207+
_preserveLayoutCacheOnInvalidateLayout = NO;
207208
}
208209
return self;
209210
}
@@ -390,7 +391,9 @@ - (CGSize)collectionViewContentSize {
390391
}
391392

392393
- (void)invalidateLayout {
393-
_minimumInvalidatedSection = 0;
394+
if (!_preserveLayoutCacheOnInvalidateLayout) {
395+
_minimumInvalidatedSection = 0;
396+
}
394397
[super invalidateLayout];
395398
}
396399

0 commit comments

Comments
 (0)