mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-23 01:08:27 +00:00
fixed Footer is sticky to the top
Summary: if `stickyHeader` is true, the footer could be sticky to the top Issue fixed: #1093 - [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) Closes https://github.com/Instagram/IGListKit/pull/1094 Differential Revision: D7246636 Pulled By: rnystrom fbshipit-source-id: 9b7da52ab46229606b530a378c01d799767e27f2
This commit is contained in:
parent
0f75e851a6
commit
afbfcbdf04
2 changed files with 22 additions and 19 deletions
|
|
@ -14,6 +14,8 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag
|
|||
### Fixes
|
||||
- Copy objects when retrieving from datasource to prevent modification of models in binding section controller. [Kashish Goel](https://github.com/kashishgoel) [(#1109)](https://github.com/Instagram/IGListKit/pull/1109)
|
||||
|
||||
- Fixed footer is sticky when `stickyHeader` is `true` [aelam](https://github.com/aelam) [(#1094)](https://github.com/Instagram/IGListKit/pull/1094)
|
||||
|
||||
3.2.0
|
||||
-----
|
||||
|
||||
|
|
|
|||
|
|
@ -319,29 +319,30 @@ static void adjustZIndexForAttributes(UICollectionViewLayoutAttributes *attribut
|
|||
|
||||
if ([elementKind isEqualToString:UICollectionElementKindSectionHeader]) {
|
||||
frame = entry.headerBounds;
|
||||
|
||||
|
||||
if (self.stickyHeaders) {
|
||||
CGFloat offset = CGPointGetCoordinateInDirection(collectionView.contentOffset, self.scrollDirection) + self.topContentInset + self.stickyHeaderYOffset;
|
||||
|
||||
if (section + 1 == _sectionData.size()) {
|
||||
offset = MAX(minOffset, offset);
|
||||
} else {
|
||||
const CGFloat maxOffset = CGRectGetMinInDirection(_sectionData[section + 1].bounds, self.scrollDirection) - CGRectGetLengthInDirection(frame, self.scrollDirection);
|
||||
offset = MIN(MAX(minOffset, offset), maxOffset);
|
||||
}
|
||||
switch (self.scrollDirection) {
|
||||
case UICollectionViewScrollDirectionVertical:
|
||||
frame.origin.y = offset;
|
||||
break;
|
||||
case UICollectionViewScrollDirectionHorizontal:
|
||||
frame.origin.x = offset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if ([elementKind isEqualToString:UICollectionElementKindSectionFooter]) {
|
||||
frame = entry.footerBounds;
|
||||
}
|
||||
|
||||
if (self.stickyHeaders) {
|
||||
CGFloat offset = CGPointGetCoordinateInDirection(collectionView.contentOffset, self.scrollDirection) + self.topContentInset + self.stickyHeaderYOffset;
|
||||
|
||||
if (section + 1 == _sectionData.size()) {
|
||||
offset = MAX(minOffset, offset);
|
||||
} else {
|
||||
const CGFloat maxOffset = CGRectGetMinInDirection(_sectionData[section + 1].bounds, self.scrollDirection) - CGRectGetLengthInDirection(frame, self.scrollDirection);
|
||||
offset = MIN(MAX(minOffset, offset), maxOffset);
|
||||
}
|
||||
switch (self.scrollDirection) {
|
||||
case UICollectionViewScrollDirectionVertical:
|
||||
frame.origin.y = offset;
|
||||
break;
|
||||
case UICollectionViewScrollDirectionHorizontal:
|
||||
frame.origin.x = offset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
attributes = [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:elementKind withIndexPath:indexPath];
|
||||
attributes.frame = frame;
|
||||
adjustZIndexForAttributes(attributes);
|
||||
|
|
|
|||
Loading…
Reference in a new issue