-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Conversation
PR Checklist (Minor Bugfix)
|
@ethanli83 - can you please sign the CLA and read our commit message guidelines? Thanks |
I have done the online form few weeks ago. |
@@ -221,7 +231,7 @@ ngMobile.directive('ngClick', ['$parse', '$timeout', '$rootElement', | |||
var y = e.clientY; | |||
var dist = Math.sqrt( Math.pow(x - touchStartX, 2) + Math.pow(y - touchStartY, 2) ); | |||
|
|||
if (tapping && diff < TAP_DURATION && dist < MOVE_TOLERANCE) { | |||
if (diff < TAP_DURATION && dist < MOVE_TOLERANCE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition is important. touchend
events can come following moves and other things that invalidate a straight-up-and-down tap, and the tapping
flag is set on touchstart
and cleared for those illegal motions.
As an example, without this, it's possible to put a finger down, move it two inches away, move it back so it's within the MOVE_TOLERANCE
again, and release, triggering a tap.
Was this deliberately removed? If so, why? If not, please put it back when you squash into one commit.
I see from the description that you deliberately changed the What device is it where this unnecessary |
Hi Braden, I never thought about your case, and I think we need to handle that for I am creating a kiosk app which is going to use a touch screen (dell So the touch events are dispatched by desktop version of Chrome, and it is Maybe we do not resetStatus() on 'touchmove' until THRESHOLD exceed? And sorry for these typos, I am quite famous with bad typing skill in my Ethan On Thu, Jul 25, 2013 at 3:40 AM, Braden Shepherdson <
|
If I understand your suggested fix correctly, it should work. I was thinking of the same thing: rather than a Be sure to include some tests, for at least three cases:
Thanks. |
Yep, exactly what I was thinking. Cheers Ethan On Thu, Jul 25, 2013 at 10:16 AM, Braden Shepherdson <
|
hi @shepheb, I have made code changes base on our discussion. I made the onTouchStart handler checks the distance between touch start and touch move and only reset tapping to false if it has moved out of the radius I also add few more tests upon your suggestions |
Any idea when this fix will be merged? |
Ping @shepheb: please provide a status update |
LGTM. |
does that mean it will be in next 1.2 build thanks |
Sooooo, this will be included in the next (rc) release? Sure hope so, I've rolled my own fastclick for now but I wouldn't mind to throw my code away for a properly integrated solution.. |
This can't work because the touchEnd listener goes through the getSingleTouchLocation(event) function which doesn't look for changedTouches, so it always returns undefined for e.clientX/Y for touchEnd. |
event = event.originalEvent || event; | ||
|
||
// get the first touch object in the event | ||
var touches = event.touches && event.touches.length ? event.touches : [event]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be
var touches = (event.changedTouches && event.changedTouches.length) ? event.changedTouches :
((event.touches && event.touches.length) ? event.touches : [event]);
For this function to work.
Issue:
I found that the ngClick directive does not work with touch events dispatched by JQuery.
JQuery will wrap touch events, and touches can only be found on originalEvent.
The touch event handlers in ngClick directive are not using the originalEvent but event instead,
so the touches these handlers use, are 'undifined'.
Also, I found browsers are quite sensitive with touch, when I just tap on my touch screen,
the browser will dispatch 'touchstart', 'touchmove', and 'touchend'. Since the touch move handler
also reset status, I never get my click handler triggered.
Fix:
Check if event has an originalEvent property, and use it instead if it is found.
Also I make touch end handler triggers click handler if the distance between touch start and touch end,
is within MOVE_TOLERANCE.