-
Notifications
You must be signed in to change notification settings - Fork 2k
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
preventDefault only works in a tap handler if the source was a click, not a touch #3567
Comments
Here is a reduced test case: http://jsbin.com/hisozi/3 It appears as though an unchecked ghost click fires on the |
Hi, Agree with lesliana. I have the same issue when I want to prevent default a track event. Thanks |
as a workaround Try to add a touchstart handler to your listener object that has tap or track handlers. You can call preventDefault on the event you receive. This event is the same event that started the tap or the tracking. listeners : {
'touchstart': '_preventDefault',
'tap': '_tapHandler'
},
_preventDefault: function(event) {
event.preventDefault();
} |
Expose setting to enable mouse handlers on touch-only devices Fixes #3567
@azakus In the polymer documentation, it says
But this is not the case for touch events. Do you think the doc should be changed ? Or maybe the sourceEvent should be the actual event and use another object to get event positions. I modified the commit so that you get the idea. |
@azakus is there any movement on this? |
* Support preventDefault() on touch Expose setting to enable mouse handlers on touch-only devices Fixes #3567 * remove experimental setting to disable touch-only detection
If you call event.preventDefault() in a tap handler, it will only prevent default if the source event was a click, but not if the source was a touch.
This means that if I have a tap handler on a site with touch input and I want to prevent default, I need to add a touchend handler and call event.preventDefault there. This leads to having two handlers for the same event (a tap and a touchend handler) in many places across the site, which isn't ideal.
In gestures.html (https://github.com/Polymer/polymer/blob/master/src/standard/gestures.html#L395), preventDefault is called for click events only, because for a touch the sourceEvent is Touch (changedTouches[0]) rather than something from the browser's event chain, like touchend.
The text was updated successfully, but these errors were encountered: