Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird scrolling bug #563

Closed
peter-szucs opened this issue Mar 17, 2021 · 16 comments · Fixed by #623
Closed

Weird scrolling bug #563

peter-szucs opened this issue Mar 17, 2021 · 16 comments · Fixed by #623

Comments

@peter-szucs
Copy link

peter-szucs commented Mar 17, 2021

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)")
    }
}
@ageevvalentin
Copy link
Contributor

This is not reproduced in version 2.4.0

@peter-szucs
Copy link
Author

Thanks for telling us this. We'll use this version until its fixed hopefully in v. 3.

@rechsteiner
Copy link
Owner

Hi @peter-szucs! Which version are you using? There was a fix for this in 3.0.1. I tried implementing you example locally, with a header view on the top and using SnapKit in the same way, and it seems to work fine here.

@peter-szucs
Copy link
Author

Hello @rechsteiner ! Thanks for your reply,
We are using 3.0.1 when getting the bug.
After downgrading to 2.4.0 the bug did dissapear though.
Let me know if you want some more code or something to look at that could help troubleshoot the issue.

@rechsteiner
Copy link
Owner

Okay, thanks. Are you able to reproduce it in one of the example projects? That would be very helpful

@peter-szucs
Copy link
Author

peter-szucs commented Apr 7, 2021

We didn't try out the example projects, and now that i've cloned it down could you tell me how to actually run it ? I can't really figure out how, it builds and thats it.
I'm still very much a beginner in iOS development. :)

link to our tryout project if you want to have a look there:
GitTryOutProject

@mishaPetrus
Copy link

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

@rechsteiner
Copy link
Owner

Thanks! Are you able to reproduce the bug in one of the examples? I haven't been able to reproduce it myself, so I can't verify that the changes are actually fixing it

@mishaPetrus
Copy link

A very strange thing, because I can't reproduce this with an Example project. I'm probably setting something wrong.

@rechsteiner
Copy link
Owner

I’m quite sure it's a problem with Parchment, because it wasn’t an issue in v2.4. I just need to reproduce it to fix it

@minaMagedNaeem
Copy link

I tried @mishaPetrus fix and it worked just fine, @rechsteiner please fix this issue ASAP or accept the answer and update the pod.

@rechsteiner
Copy link
Owner

rechsteiner commented May 30, 2021

@minaMagedNaeem I need to be able to reproduce it in order to provide a reliable fix. If you have any details on how to reproduce it that would be great. Even better if you are able to reproduce it in one of the example projects

@BaoDotMark
Copy link

BaoDotMark commented Jul 29, 2021

I got this exact scrolling issue. I have 5 menus: 1st(20 items) - 2nd(20 items) - 3rd(10 items) - 4th(20 items) - 5th(10 items). When I scroll from 20 items -> 10 items or 10 -> 20, this bug happens. It's normal from 1st menu to 2nd menu.

@toptomsk
Copy link

toptomsk commented Aug 31, 2021

I got this issue too, and misha's answer work great for me. But pullToRefresh will not work in this case. Hope you guys will fix it.

@toptomsk
Copy link

toptomsk commented Nov 5, 2021

@rechsteiner Hi Martin!
I have messaged example to your twitter, hope u check it and can find out this bug.

@sugitatestblue
Copy link
Contributor

@ageevvalentin
Thank you fix it.
However, the fix version didn't release yet.
I wanted the hash of c8ec776
but, I couldn't set the hash version on Swift Packaging Manger.
I should use 2.4.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants