Parchment: Weird scrolling bug

Hi! First of all thanks for a great library!

We recently decided to try and incorporate this into our app since it would suit our needs perfectly. We also added a collapsing header effect with it. So we first made a test project to test it out and just as we had refactored it into our own app we noticed a very strange bug that we just can’t seem to pinpoint the problem with. At first we thought maybe its something in our own app but i opened up the test project and its there as well.

This GIF will show you the issue. Its even worse when we only have one tab/screen. It then even gets hard to scroll down for a refresh properly without triggering this issue.

parchmentBug

Do you have any idea as of why and where this might be happening ?

Sample code for implementation:

private var pagingViewController = PagingViewController()

pagingViewController.dataSource = self
pagingViewController.register(PagingCustomCell.self, for: CustomPagingItem.self)
addChild(pagingViewController)
pagingViewController.borderOptions = .hidden
pagingViewController.menuItemSize = .selfSizing(estimatedWidth: 100, height: 40)
pagingViewController.indicatorClass = CustomIndicatorView.self
pagingViewController.indicatorOptions = .visible(
    height: 32,
    zIndex: -1,
    spacing: .zero,
    insets: UIEdgeInsets(top: 0, left: 0, bottom: 5, right: 0)
)
pagingViewController.indicatorColor = .purple
pagingViewController.collectionView.contentInset = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)

view.addSubview(pagingViewController.view)
pagingViewController.backgroundColor = .clear
pagingViewController.didMove(toParent: self)
pagingViewController.view.translatesAutoresizingMaskIntoConstraints = false
pagingViewController.view.snp.makeConstraints { (m) in
    m.top.equalTo(headerView.snp.bottom)
    m.left.right.bottom.equalToSuperview()
}

// Put shadow beneath tabs for collapsing header
pagingViewController.collectionView.layer.masksToBounds = true
pagingViewController.collectionView.layer.shadowOffset = CGSize(width: 0, height: 1)
pagingViewController.collectionView.layer.shadowRadius = 1
pagingViewController.collectionView.layer.shadowOpacity = 0.3

extension ViewController: PagingViewControllerDataSource {
    
    func numberOfViewControllers(in pagingViewController: PagingViewController) -> Int {
        return pages.count
    }
    
    func pagingViewController(_: PagingViewController, viewControllerAt index: Int) -> UIViewController {
        let currentVc = pages[index]
        
        if let currentVc = currentVc {
            return currentVc
        } else {
            let tableViewVC = TableViewController()
            tableViewVC.innerTableViewScrollDelegate = self
            
            pages[index] = tableViewVC
            
            return tableViewVC
        }
    }
    
    func pagingViewController(_: PagingViewController, pagingItemAt index: Int) -> PagingItem {
        return CustomPagingItem(index: index, text: "View \(index+1)")
    }
}

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 16 (7 by maintainers)

Most upvoted comments

Hello @rechsteiner. First of all thanks for a perfect library!

In general, I have the same problem with scrolling. I found the place in the library, where it can be fixed. As you can see on the screenshot scrollView.contentOffset has vertical and horizontal offset. If you uncomment the code, horizontal scrolling will work well.

Screenshot 2021-04-08 at 16 04 58

This is not reproduced in version 2.4.0