scenee / FloatingPanel

A clean and easy-to-use floating panel UI component for iOS
MIT License
5.6k stars 509 forks source link

How to dismiss fpc by drag content controller's scroll view #530

Closed karthuszY closed 1 year ago

karthuszY commented 2 years ago

Description

When the fpc contentViewController has scrollView, i can't dismiss it by drag the content. It's now only can drag the grabberHandle area to dismiss.

Expected behavior

When scroll view is at top, drag it to dismiss fpc.

scenee commented 2 years ago

FloatingPanelController doesn't track a scroll view in the content automatically. Please call this method to recognize a scroll view to it.

let fpc = FloatingPanelController()
...
fpc.track(scrollView: contentVC.scrollView)
karthuszY commented 2 years ago

FloatingPanelController doesn't track a scroll view in the content automatically. Please call this method to recognize a scroll view to it.

let fpc = FloatingPanelController()
...
fpc.track(scrollView: contentVC.scrollView)

I have tried it. But it still does not work? Should I config anything more?

futuretap commented 1 year ago

This doesn't work for me, at least only partially.

What does work is to quickly flick and let go. Then the scrollView bounce is connected with a bounce of the panel. However, when starting the scroll from an offset below the top and dragging towards the bottom, the scrollView simply stops scrolling and the panel doesn't move.

I've added this to the extension MainViewController: UITableViewDelegate in SearchViewController.swift:

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    fpc.followScrollViewBouncing()
}

I analyzed the problem and found that due to calling lockScrollView(strict: true) the scrollView no longer sends didScroll events. The gesture handling code is quite complex, so I'm unaware how to fix this. @scenee, can you take a look?

https://github.com/scenee/FloatingPanel/assets/110374/3c14fd32-f65e-4fb8-ac3b-c4fd9f75c7fe

scenee commented 1 year ago

@futuretap Thank you for providing your feedback. I greatly appreciate it. Your screen recording has helped me understand the steps to reproduce this issue. After debugging the code, I found the root cause is that the prioritization of panel and scroll gestures. I will continue to investigate and resolve this issue.

futuretap commented 1 year ago

thanks, looks good!

futuretap commented 1 year ago

Btw, Apple's Maps app suffers from the exact same problem. They should use your implementation 😉

scenee commented 1 year ago

It's the power of community! Thanks for your help 😄