FloatingPanel
FloatingPanel copied to clipboard
Is it real to continue scrolling when state changes to .full or .tip?
Expected behavior
i do scrolling and after floating panel state became on .full or .tip scrollView have to continue scrolling. I can do it if i add more force by my finger, but how can i do it without extra force?
Actual behavior
When panel state became .full or .tip content scrolling stopped.
Code example that reproduces the issue
class FloatingPanelFactory {
static func trendFloatingPanelController() -> FloatingPanelController {
let fpc = FloatingPanelController()
fpc.layout = TrendsFloatingPanelLayout()
fpc.surfaceView.grabberHandle.isHidden = true
fpc.addSBAppearance()
return fpc
}
}
extension FloatingPanelController {
func addSBAppearance() {
let appearance = SurfaceAppearance()
appearance.cornerRadius = 16
appearance.backgroundColor = .white
self.surfaceView.appearance = appearance
}
}
fileprivate class StickerPackDetailsFloatingPanelLayout: FloatingPanelLayout {
let position: FloatingPanelPosition = .bottom
let initialState: FloatingPanelState = .tip
var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring] {
return [
.full: FloatingPanelLayoutAnchor(absoluteInset: TrendViewController.headerHeight + 10, edge: .top, referenceGuide: .safeArea),
.tip: FloatingPanelLayoutAnchor(absoluteInset: TrendBannersView.viewHeight + 60, edge: .top, referenceGuide: .safeArea),
]
}
func backdropAlpha(for state: FloatingPanelState) -> CGFloat {
switch state {
case .full, .half: return 0.0
default: return 0.0
}
}
}
//in ViewController
private func addFloatingPanel() {
fpc = FloatingPanelFactory.trendFloatingPanelController()
fpc.delegate = self
fpc.view.translatesAutoresizingMaskIntoConstraints = false
tableViewController = TrendLinesViewController()
fpc.panGestureRecognizer.delegateProxy = self
fpc.set(contentViewController: tableViewController)
fpc.track(scrollView: tableViewController.tableView)
fpc.addPanel(toParent: self)
fpc.contentMode = .fitToBounds
}
extension TrendViewController: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return false
}
}
extension TrendViewController: FloatingPanelControllerDelegate {
func floatingPanelDidMove(_ vc: FloatingPanelController) {
if vc.isAttracting == false {
let loc = vc.surfaceLocation
let minY = vc.surfaceLocation(for: .full).y
let maxY = vc.surfaceLocation(for: .tip).y
vc.surfaceLocation = CGPoint(x: loc.x, y: min(max(loc.y, minY), maxY))
}
}
}
This looks the same as https://github.com/scenee/FloatingPanel/issues/455. Is it right? If so, it's not easy but I'm addressing the issue now 👍