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

Tap events get passed to the parent #317

Closed
Mattijah opened this issue Feb 9, 2020 · 11 comments
Closed

Tap events get passed to the parent #317

Mattijah opened this issue Feb 9, 2020 · 11 comments

Comments

@Mattijah
Copy link

Mattijah commented Feb 9, 2020

Only a perfect, direct taps get recognised by UIButton. In case of a little movement, the tap event is passed to the parent and handled by the pan gesture.

Can be tested in: Samples > Show Panel Modal (contains 3 buttons)

Steps:

  • Tap and move the cursor/finger a little bit, then lift up (this tends to happen frequently in a real-world with fast taps done in a rush)
  • Tap is ignored and "Detail panel is tapped!" message gets printed

Instead, any touchUpInside that happens within the actual button should be registered. This makes more sense in cases where buttons are displayed in the content view, but the stay fixed at certain position and don't move with the panel (imagine something like a tabbar that comes up, but then stays fixed). How can the pan gesture in such cases be disabled? I couldn't find any relevant delegate methode, moreover panGestureRecognizer.delegate cannot be modified.

@scenee
Copy link
Owner

scenee commented Feb 28, 2020

I will check this issue after releasing v1.7.3.

@scenee
Copy link
Owner

scenee commented May 15, 2020

@Mattijah
Sorry it took me so long to reply. The problem you pointed out is the one we face when dealing with a gesture recognizer and UIButton at the same time.
To solve this, we can use set FloatingPanelController.panGestureRecognizer up as follows.

fpc.panGestureRecognizer.cancelsTouchesInView = false

I think this will make it work the way you expect it to.

@Mattijah
Copy link
Author

Thanks @scenee. This does seem to help. It is still not 100% and hovering with a finger over the button affects the underlying panel (it moves up/down - so that means it also accepts touches), but at least the touchUpInside event now gets recognised.

@scenee
Copy link
Owner

scenee commented May 28, 2020

@Mattijah
Oh I see. Alright, I'm going to consider the solution again for hovering a button with a finger.

@make2a
Copy link

make2a commented Aug 27, 2020

@scenee pod 'FloatingPanel', '~> 2.0.0-beta.1' has same issue.

@scenee
Copy link
Owner

scenee commented Aug 29, 2020

Thank you, @make2a. I will take a look at his issue on v2.

Note: This issue might be related to #157

@scenee
Copy link
Owner

scenee commented Sep 5, 2020

@make2a
This issue seems to be resolved by stoping UITapGestureRecognizer with the panel pan gesture simultaneously by the following options.

v1: Returns false in floatingPanel(_:shouldRecognizeSimultaneouslyWith:) delegate method.
v2: Returns false in gestureRecognizer(_:, shouldRecognizeSimultaneouslyWith:) method of the delegate assigned to fpc.panGestureRecognizer.delegateProxy.

@macshodan
Copy link

Hi, first of all thanks for this great library.
I'm having a similar issue after updating to version 2.0.x. Basically I've implemented something similar the actual Maps app, where the user has a floating panel displaying a collection view with the details of each poi visible on the map.
When the user taps a poi on the map the current floating panel automatically hides and a new one with only the content of the selected poi (or cluster) is shown instead.
The two controllers that handle the floating panel are the same, only different instances with some parameters the add a button to dismiss the panel on the "second" one.

On both instances the collection view works normally, it scrolls and select items, but the uibutton to programmatically close the floating panel don't work unless I first drag the floating panel. I can see the button tapped but the associated action won't be called. I've tried to add the same button on the first instance, and it works flawlessly. One side note is that when I instantiate the first fpc I didn't set the panGestureRecognizer.delegateProxy, I've tried adding it for the second panel with no luck.

@scenee
Copy link
Owner

scenee commented Nov 7, 2020

Hi, @macshodan. Does your problem still occure on v2.0.1? Because v2.0.1 has a bug fix on a button tap, #396.

@macshodan
Copy link

Hi, @macshodan. Does your problem still occure on v2.0.1? Because v2.0.1 has a bug fix on a button tap, #396.

Hi @scenee, just tried and it's fixed. Thanks a lot for your support!

@gunnarsson
Copy link

The 2.0.1 fix solved a similar issue for me, moving the panel using move(to:animated:) made all buttons inside stop working until the panel was dragged. Thank you so much for the fix!

@scenee scenee closed this as completed Dec 12, 2020
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

No branches or pull requests

5 participants