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

stopPropagation not working? #32

Open
justinshea opened this issue Nov 8, 2014 · 7 comments
Open

stopPropagation not working? #32

justinshea opened this issue Nov 8, 2014 · 7 comments

Comments

@justinshea
Copy link

Hi,
I recently updated to most recent hammer.js and jquery.hammer.js . I was previously using jquery.hammer-full.js. There seem to be some major changes in usage that I am just feeling out. One significant change seems to be that there are no more methods in event.gesture like "stopPropagation" and "stopDetect" -- calling these will now return "undefined". Seeing this I thought I could use "stopPropagation" method in the top level event in order to stop a touch event from bubbling up the DOM like I would for any "standard" event. However, this doesn't seem to work:
http://jsfiddle.net/justinshea/4tL6xub1/
In the example you will notice that tapping on the innerbox will bubble to outerbox even though stopPropagation is called for tap event in innerbox..Not sure if this is an "issue" or if I am just missing something??? any/all feedback is appreciated...
Thanks,
Justin

@mciparelli
Copy link

Yeah I had a hard time figuring out this and actually I couldn't get simple jQuery delegation to work properly, like:

$ul.on('tap', 'li', doStuff);

But if you do the following apparently it will prevent the tap in the outer box:

$('.innerBox').hammer({domEvents: true}).on("tap", function(e){
    e.gesture.stopPropagation();
});

@justinshea
Copy link
Author

Thanks for the feedback. I tried adding the "domEvents" option but that still doesn't work (btw -where is the documentation on this option? I cant find it anywhere).

I Think this is a bug..the preventDefault and stopPropagation methods are simply unavailable within the gesture object and, using the method from the top-level of the jquery event is not recognized by hammer.

@adamgins
Copy link

FYI, I came across this: https://github.com/josdejong/propagating-hammerjs I am about to try it

@adamgins
Copy link

Quick update - I can't seem to get the above package working on Meteor as it's NPM and it would have to be server side. So no luck. and I have the issue with my "press" events are still propagating up the DOM tree. Any help appreciated.

@adamgins
Copy link

FYI @justinshea @mciparelli - I got this working with https://github.com/josdejong/propagating-hammerjs as per josdejong/propagating-hammerjs#1

With no disrespect for @josdejong 's good work it would be nice if this just worked out of the box (pretty please)

@josdejong
Copy link

See also hammerjs/hammer.js#652

Yeah, event propagation is quite a corner stone of event handling in the browser. It's too bad that hammer.js doesn't (yet?) support this.

@BigerXie
Copy link

hi guys, do you have plan to fix it?

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