hammerjs / hammer.js

A javascript library for multi-touch gestures :// You can touch this
http://hammerjs.github.io
MIT License
24.12k stars 2.63k forks source link

Recognizers for overlapping Hammer instances will both fire. #807

Open runspired opened 9 years ago

runspired commented 9 years ago

There should be a better eventing / delegation / bubbling pattern to prevent the issues this creates.

This is a meta issue, the following other issues are affected by it in some way:

https://github.com/hammerjs/hammer.js/issues/735 https://github.com/hammerjs/hammer.js/issues/727 (issues with tap/click similarities) https://github.com/hammerjs/hammer.js/issues/690 https://github.com/hammerjs/hammer.js/issues/652

josdejong commented 9 years ago

Thanks for picking this up! It would be really great if hammer.js would support event propagation.

Out of necessity I've built an extension on top of hammer.js offering event-propagation: https://github.com/josdejong/propagating-hammerjs. I hope this solution can retire soon!

arschmitz commented 9 years ago

@josdejong Thank you! We have already been having talks around this and the best way to handle it. Right now the talks have focused on moving closer to native events.

josdejong commented 9 years ago

Thanks, keep up the good work.

robstown commented 8 years ago

Thanks all who contributed, this is an awesome library. @josdejong, your propagating extension helps, but I guess I first interpreted the readme wrong as I though firstTarget was referring to what is normally currentTarget, but I see it is instead the top element that the original event started on. Is there still movement to incorporate propagation into hammer.js as well as closing #653 (linked to this issue)?

dcbartlett commented 8 years ago

Is there any progress/work done to integration propagation into Hammer.JS. If not i'd like to help out.

arschmitz commented 8 years ago

@dcbartlett there has not been yet we are happy to have a PR though!

Smona commented 7 years ago

I ran into this issue as well, and am having success using @josdejong 's propagating-hammerjs. This functionality is totally vital for more complex UIs, and would be nice to have included in hammerjs by default.

If nobody has time to work on this issue, it seems a quick fix could be to just add propagating-hammerjs as a dependency and wrap every Hammer instance with it, or provide a configuration option for enabling it.

parox2014 commented 5 years ago

@josdejong thank you very much,I resolve this problem by your plugin 👍

joker-777 commented 5 years ago

I created a small codepen for this bug https://codepen.io/kenhub/pen/yWgLmj

ivanmiiranda commented 4 years ago

what is the configuration from this plugin with angular 6/7 in main.ts

VilOstreiko commented 4 years ago

@josdejong is there any possible way to include your plugin to angular application? I use hammerjs just importing it as a module and providing with HAMMER_GESTURE_CONFIG injection token.

josdejong commented 4 years ago

@VilOstreiko I don't know.

deerawan commented 3 years ago

Interestingly, there's a unit test to check this propagation behavior and the test is passed. 🤔

https://github.com/hammerjs/hammer.js/blob/master/tests/unit/test_propagation_bubble.js#L44