-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Prevent tap on parent element #652
Comments
Yes, how to stop event propagation? Here is my experiment: http://jsbin.com/xohasi/edit?html,output See this related issue on stackoverflow: http://stackoverflow.com/questions/25530040/how-to-stop-hammer-js-event-propagation |
You don't need to call preventDefault or stopPropagation. Neither of them will work. Instead in your parent container check what the event.target is. If it is not the parent container and is set to the child container then ignore the event. |
Yes, that's true, though having the parent to know about all it's childs (and the childs of its childs, etc) leads to highly coupled code. The nice thing about the browsers event delegation is that you can leave parent en childs independent of each other. So the only alternative is to write our own event delegation solution :( |
+1, also looking for a viable solution. I'm using a 3rd party lib that uses Hammer too, and its |
I just created a mixin to extend hammer.js with event propagation: https://github.com/josdejong/propagating-hammerjs Still working on a proper API. Right now you extend an instance like |
I can confirm that |
Closing this in favor of #807 |
Guys, could you instruct me on what the implementation would look like the other way around? I have a navigation bar that is invoked/shown in the app via a right swipe gesture. So I need to either find a way to:
I'm using Hammer.JS - v2.0.8
|
How do we prevent the parent element from receiving the tap event, when we tap a child element?
I've tried to call
event.preventDefault()
andevent.srcEvent.stopPropagation()
, but none seem to work :-(I've placed an example at: http://codepen.io/anon/pen/qDisl
The text was updated successfully, but these errors were encountered: