-
-
Notifications
You must be signed in to change notification settings - Fork 514
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
Use scrollView.contentOffset when stopping ongoing scroll deceleration #527
Conversation
Thank you for your PR. Unfortunately, I found a problem where the content offset of a tracking scroll view sometimes slips after I swipe a panel up from the half state to full state. I will upload a screen record later. |
Please post your findings, I will try to further look into this issue. |
Here is a screen record when I reproduced this issue. content-slips.mp4I guess we might need to modify a condition where |
I started investigating how FloatingPanel/Sources/Core.swift Lines 801 to 806 in e39f634
I noticed that replacing it with |
In general it seems as if either |
I confirmed your PR it's working well! And then thanks to your comments, I knew the root cause is So I pushed the commit of an alternative solution to update the behavior of This solution is a bit side effect but it works |
Glad I could help! Unfortunately I am getting some really strange behaviour after your changes to the implementation of Simulator.Screen.Recording.-.iPhone.13.Pro.-.2022-01-31.at.12.30.18.mp4 |
Create a new StoryBoard project and paste this into the ViewController file, the example is as basic as possible. I think the issue with: 5181ccd is that Meanwhile the change in de34fda is localised too that single place. ///
// ViewController.swift
// FloatingPanelLab
//
// Created by Jakub Dudek on 2022-01-18.
//
import UIKit
import FloatingPanel
class ViewController: UIViewController {
private lazy var floatingPanelController: FloatingPanelController = {
let fpc = FloatingPanelController()
fpc.set(contentViewController: tableViewController)
fpc.track(scrollView: tableViewController.tableView)
return fpc
}()
private lazy var tableViewController: TableViewController = {
let vc = TableViewController()
return vc
}()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .yellow
view.addSubview(floatingPanelController.view)
floatingPanelController.view.frame = view.bounds
addChild(floatingPanelController)
floatingPanelController.didMove(toParent: self)
floatingPanelController.show()
}
}
class TableViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
let tableView = UITableView()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .red
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.dataSource = self
tableView.delegate = self
view.addSubview(tableView)
NSLayoutConstraint.activate([
tableView.topAnchor.constraint(equalTo: view.topAnchor),
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
])
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 20
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell.textLabel?.text = "\(indexPath.row)"
return cell
}
} |
The issue is with private func allowScrollPanGesture(for scrollView: UIScrollView) -> Bool {
guard state == layoutAdapter.mostExpandedState else { return false }
var offsetY: CGFloat = 0
switch layoutAdapter.position {
case .top, .left:
offsetY = value(of: scrollView.fp_contentOffsetMax - scrollView.contentOffset)
case .bottom, .right:
offsetY = value(of: scrollView.contentOffset - contentOffsetForPinning(of: scrollView))
}
return offsetY <= -30.0 || offsetY > 0
}
|
Thanks to your detail comments, I've realized I misunderstood that de34fda affected |
5181ccd
to
de34fda
Compare
No reason to apologise, glad to hear that things are working as intended. I really enjoy using your library, very happy that I could contribute a little. |
Thank you for saying that. I'm so glad. |
This commit sets the initial scroll offset to the pinning offset. The previous implementation, which set it to the current content offset, leads various scroll tracking bugs. This reproduction is one of issues. Using 'Scroll tracking(UITableView)' in Samples app. 1. Bounce the scroll content at the top most anchor. 2. Pull down the panel in bouncing at a minus content offset. (the scroll content stops at the minus offset.) 3. Pull up it The previous implementation was implemented for #526/#527. But now the issue hasn't been reproduced in v2.5.6.
Applies fixes as described in #526