ngTouch - Keep track of touch by identifier #7935
Description
I am currently developing a multitouch application and tried to use ngTouch
here. I stumbled upon an implementation which can handle only one touch at a time. I am wondering if this is done by purpose as i dont know about the side effects of my idea.
Right now ngTouch alters the ng-click
directive, so it will work with touch events, but the implementation works with only one touch at a time.
Any OS, any Browser
Angular and ngTouch Version 1.2.17
I created a plunkr to demonstate, please use a touch device with multiple touches:
http://plnkr.co/edit/s2vkc4neFzha6nsBSGQG
If you hold one button, the other one will not work anymore, altough the touchstart
and touchend
events are triggered. I think this is due to 3 reasons:
- The
touchstart
event handler on the element takes the first touch in the list oftouches
instead of thetargetTouches
. If there is another touch in progress it will take it as thetouchstart
coordinates which is wrong (at least semantically) since this is not the touch which occured. - The
preventGhostClick
function can only handle one event too. - The
tapping
property gets reset if any touch move event happens
In my case i am trying to use a 2D-Joystick which gets dragged around all the time. Additionally i want to trigger some other stuff like a horn. I looked for a solution to get this behavior, but had no success, the only thing left would be to attach the touch handlers manually.
I would be glad to provide a pull request if wished.
Note: Currently there is a problem if jQuery included, the starting coordinates are NaN for the touchstart. See #4583