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
This commit is contained in:
Constantine Fry 2025-09-08 02:47:19 -07:00 committed by Facebook GitHub Bot
parent 0944f8e809
commit 700905e628
2 changed files with 9 additions and 1 deletions

View file

@ -97,6 +97,11 @@ NS_SWIFT_NAME(ListCollectionViewLayout)
*/
@property (nonatomic, assign) BOOL showHeaderWhenEmpty;
/**
Set this to `YES` to keep layout cache when invalidateLayout is called. Default is `NO`.
*/
@property (nonatomic, assign) BOOL preserveLayoutCacheOnInvalidateLayout;
/**
Create and return a new collection view layout.

View file

@ -204,6 +204,7 @@ static void adjustZIndexForAttributes(UICollectionViewLayoutAttributes *attribut
UICollectionElementKindSectionFooter: [NSMutableDictionary new],
}];
_minimumInvalidatedSection = NSNotFound;
_preserveLayoutCacheOnInvalidateLayout = NO;
}
return self;
}
@ -390,7 +391,9 @@ static void adjustZIndexForAttributes(UICollectionViewLayoutAttributes *attribut
}
- (void)invalidateLayout {
_minimumInvalidatedSection = 0;
if (!_preserveLayoutCacheOnInvalidateLayout) {
_minimumInvalidatedSection = 0;
}
[super invalidateLayout];
}