Fix logic flaw of of shouldInvalidateLayoutForBoundsChange in IGListCollectionViewLayout (#1236)

Summary:
Issue fixed: #1235

- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Pull Request resolved: https://github.com/Instagram/IGListKit/pull/1236

Reviewed By: lorixx

Differential Revision: D12839081

Pulled By: rnystrom

fbshipit-source-id: 3e9e1192f16912d560d76f3730a377f303708cd7
This commit is contained in:
Allen Hsu 2018-11-01 14:53:16 -07:00 committed by Facebook Github Bot
parent 3f31d05ac3
commit 8ebde97b92
2 changed files with 7 additions and 2 deletions

View file

@ -36,6 +36,7 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag
- Fixed crash when using `-[IGListCollectionContext dequeueReusableCellOfClass:withReuseIdentifier:forSectionController:atIndex:]` [Jeremy Lawrence](https://github.com/ziewvater) (tbd)
- Fixed logic flaw in `[IGListCollectionViewLayout shouldInvalidateLayoutForBoundsChange:]`. [Allen Hsu](https://github.com/allenhsu) (tbd)
3.4.0
-----

View file

@ -415,13 +415,17 @@ static void adjustZIndexForAttributes(UICollectionViewLayoutAttributes *attribut
- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds {
const CGRect oldBounds = self.collectionView.bounds;
// always invalidate for size changes
if (!CGSizeEqualToSize(oldBounds.size, newBounds.size)) {
return YES;
}
// if the y origin has changed, only invalidate when using sticky headers
if (CGRectGetMinInDirection(newBounds, self.scrollDirection) != CGRectGetMinInDirection(oldBounds, self.scrollDirection)) {
return self.stickyHeaders;
}
// always invalidate for size changes
return !CGSizeEqualToSize(oldBounds.size, newBounds.size);
return NO;
}
- (void)prepareLayout {