IGListKit
IGListKit copied to clipboard
Scrolling offset might be wrong when scrolling backwards using scrollToObject: method
New issue checklist
- [x] I have reviewed the
README
and documentation - [x] I have searched existing issues and this is not a duplicate
General information
-
IGListKit
version: 3.0 - iOS version(s): 11.4
- CocoaPods/Carthage version:
- Xcode version: 9.4.1
- Devices/Simulators affected: all
- Reproducible in the demo project? (Yes/No): Yes
- Related issues: /
Debug information
Hi, i am using IGListKit with supplementaryHeaderViews but i am facing an issue when i want to use the scrollToObject:
method inside the adapter. When the visible sections are greater then the one that i want to scroll to it scrolls to the correct object but the sections are not fully visible.
You can reproduce the issue in one of the Demo Projects, the one for the Supplementary Views if you scroll to bottom manually but add scroll to index 0 to be executed after some delay. I am using the following code:
let item = feedItems[0]
DispatchQueue.main.asyncAfter(deadline: .now()+5) {
self.adapter.scroll(to: item, supplementaryKinds: [UICollectionElementKindSectionHeader, UICollectionElementKindSectionFooter], scrollDirection: .vertical, scrollPosition: .top, animated: true)
}
Am i doing something wrong or the contentOffset calculations is bad.
Thank you !
@darko55s what is the actual bug? Have you done any digging into this?
Hey @rnystrom, sorry for late response, the is issue is that the scrollToObject is not calculating the height of the supplementaryHeaderViews. So when you do scrollToObject on a section that is not visible(when it need to scroll backwards) the first cell of the sectionController is not fully visible. The part that is not visible has the exact height as the supplementaryHeaderView height.
Also the same happens when you use scrollToSectionController: on the collectionContext object. It scrolls to the correct section and index but the visible area of the topmost cell is cut by the supplementaryHeaderView.
P.S. The supplementaryHeaderView are sticky i am using this :
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: ListCollectionViewLayout(stickyHeaders: true, topContentInset: 0, stretchToEdge: true))
I'm able to reproduce this. Will look into a fix.
I will look into it as well