-
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
Can't cancel click event after handling tap event #240
Comments
I'm having this same issue - were you able to find a solution? If so, would you mind sharing? |
It's not a Hammer issue really, but rather just the way client events propagate. Hammer isn't replacing all default events but rather augmenting it, so default stuff like Click still fires. https://developers.google.com/mobile/articles/fast_buttons touchs upon the idea of this "ghost click", so I ended up doing something simliar to 'capture' that click, though I opted to remove the coordinate requirement. |
It might be an idea to create a fastClick plugin for Hammer, someday |
Yeah, that'd be super-helpful (to me at least). I'll add it to my list here... maybe hack at it over the weekend. I'm sort of stumped on how to handle this ghost click thing... i'm calling ev.preventDefault(), ev.gesture.preventDefault() (and all related bits like stopDetect() and stopPropagation() ) from my "tap" event handler but nothing short of reverting to plain touchstart event + preventDefault() is killing off the ghost click. In my scenario, the tap is closing / destroying dom elements... so the underlying elements are receiving the ghost click. Any suggestions? I suppose I can just use touchstart and be done with it... btw, thanks for a great lib! |
Hammer's events are parallel to the click event you're trying to cancel, so that won't be able to work. I had the same problem with "content shifting" after the tap event. I ended up creating my own app function preventClick() that I can attached to my event handlers to kill the click if it fires. |
can you show the code of that method? sounds interesting |
@cheneytsai can you post a gist of what you did? |
Sorry been AWOL. My code involved invoking a global click handler thats eats the click with expiration delay. It was hacky and I wouldn't recommend using it. I think there was a fix #314 that was since merged in that should address the issue though. |
hey, i have come across this issue recently, too. check out this fiddle: http://jsfiddle.net/ZFC6p/4/ |
It is worth noticing that the following line will not work if you scroll the window between the tap event and the click event.
|
I'm having a issue where I'm unable to stop the default click event after I handle a Tap event.
Example:
Imagine buttons on top of each other. I have a tap handler on the top button that removes the button from the Dom, but then the click event fires 300ms later on the button underneath.
Tap - > Remove Button - > Click happens in the same coordinates.
Ideally, I would like to be able to cancel the click in my handler that also removes the button. Any thoughts? Thanks!
Let me know if you want me to reproduce.
The text was updated successfully, but these errors were encountered: