diff --git a/CHANGELOG.md b/CHANGELOG.md index 03c8efb0..47fcfed9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ----- diff --git a/Source/IGListCollectionViewLayout.mm b/Source/IGListCollectionViewLayout.mm index 06c5097a..8ee577a5 100644 --- a/Source/IGListCollectionViewLayout.mm +++ b/Source/IGListCollectionViewLayout.mm @@ -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);