IGListKit icon indicating copy to clipboard operation
IGListKit copied to clipboard

Scrolling offset might be wrong when scrolling backwards using scrollToObject: method

Open darko55s opened this issue 6 years ago • 4 comments

New issue checklist

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 avatar Aug 13 '18 13:08 darko55s

@darko55s what is the actual bug? Have you done any digging into this?

rnystrom avatar Oct 27 '18 21:10 rnystrom

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))

darko55s avatar Nov 06 '18 15:11 darko55s

I'm able to reproduce this. Will look into a fix.

iperry90 avatar Nov 11 '19 19:11 iperry90

I will look into it as well

Annastaciahubbard avatar Nov 11 '19 19:11 Annastaciahubbard