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

When the number of touch points changes, unexpected movement occurs #596

Closed
mkv123 opened this issue Jul 13, 2014 · 15 comments
Closed

When the number of touch points changes, unexpected movement occurs #596

mkv123 opened this issue Jul 13, 2014 · 15 comments
Assignees
Labels

Comments

@mkv123
Copy link

mkv123 commented Jul 13, 2014

I noticed that when the user changes from using two touches for rotation to one touch, dragging, the deltaX and deltaY and velocities jump.

From a usage perspective when doing panning, if the persons fingers don't move, it would be expected that the surface below doesn't move, even if they lift a finger from the screen. However I assume that because the center of the gesture moves, this causes deltaX and deltaY to change which in turn causes a velocity to be generated.

I've worked around the deltaXY changing by detecting when the number of touches changes, or when the finger identifier changes, and compensating for the jump in deltaXY but I haven't figured out how to compensate for the velocity.

Using Hammer.js would be easier if the deltaX, deltaY and velocities would relate to the user's fingers moving on screen, rather than the center point of the gesture changing. Tracking the center point moving does work, but only when the number of touches remains constant through the gesture.

@jtangelder jtangelder added the v2 label Jul 13, 2014
@jtangelder
Copy link
Member

Hm interesting issue. I've been experiencing this as well and thought about a proper way to fix this.

Changing deltaX/Y to the primary (the first) touch would solve these issues. But the first touch doesnt have to be the last touch, thus not primary anymore, and then it's jumping again...

I guess that the changing the center position to stay at the relative position after a touch is released should fix the jumping around of the values. I will look into this today, i think this issue is a serious one!

@jtangelder jtangelder self-assigned this Jul 13, 2014
@mkv123
Copy link
Author

mkv123 commented Jul 13, 2014

The problem of tracking deltaXY for the primary touch is that that primary touch might change, i.e. going from drag with finger 1 to rotation with fingers 1 and 2 to drag with finger 2. In this case you'd need to switch to tracking deltaXY on the second finger which might cause the jump to occur. Also I'm not sure it would work well when trying to detect a two finger drag at the same time with rotation.

Probably to some extent there will be need to track the gesture center, but detect when touches get added/removed and this causes a shift in the center and don't count those in.

Edit: Reading your comment more carefully it looks like I've mostly re-iterated what you already wrote :O)

@mkv123
Copy link
Author

mkv123 commented Jul 13, 2014

Maybe tracking relative deltas for each finger could work. I.e. track the change/delta for each finger since the previous deltaXY update and take the average. The important bit is that the delta for each finger would be relative deltas since the previous calculation, and thus wouldn't maybe get skewed as fingers are added and removed.

@jtangelder
Copy link
Member

I think i've fixed it: b29ea29
Could you confirm it suits you? I've updated the visual demo as well to make it feel better:
http://cdn.rawgit.com/hammerjs/hammer.js/master/tests/manual/visual.html

@mkv123
Copy link
Author

mkv123 commented Jul 25, 2014

With the current version, I'm seeing the rotation go completely 180 if I lift one fingers after a combined pinch-rotation. Steps to reproduce:

  • Right finger down, Left finger down, rotate, right finger up (here rotation goes -180), left finger up

@mkv123
Copy link
Author

mkv123 commented Jul 25, 2014

With a mouse doing the following: mouse down, move, stop for 1s, mouse up -> always non-zero velocity. As the mouse pointer wasn't moving for 1s, I would expect zero velocity.

@mkv123
Copy link
Author

mkv123 commented Jul 25, 2014

Testing was done on ace519d “Fix rotate” version in git.

@mkv123
Copy link
Author

mkv123 commented Jul 25, 2014

The rotation issue I'm seeing is likely this one: #610

@jtangelder
Copy link
Member

Could create a new issue for #596 (comment)?

@mkv123
Copy link
Author

mkv123 commented Jul 26, 2014

Ok: #620

@mkv123
Copy link
Author

mkv123 commented Jul 26, 2014

It is difficult to verify if this original issue is now fixed or not. The issues #620, #596 and #610 are the current problems I'm seeing, but they make it difficult to see if there is jumping in the delta values. Perhaps it is best to close this for now, and I can re-open it if I'm still seeing it after the three other bugs are fixed.

@jtangelder
Copy link
Member

👍
The deltaXY issue is solved, the issues you've opened are just small other bugs that have to be fixed asap. I think i will release the 2.0.2 this weekend!

@morph85
Copy link

morph85 commented Feb 6, 2015

I'm having issue even with v2.04 in iOS devices.
The element will rotate 180 degree when i tap using two finger, followed by one finger and vice versa.

I managed to do a work around for this issue using code below, just for temporary measure:
if (ev.rotation < 120 && ev.rotation > -120) {
// assume user will not twist their finger so much to more than 120 degree
rotate = ev.rotation;
}

@mkv123
Copy link
Author

mkv123 commented Feb 6, 2015

morph85: Thanks for writing that there are still bugs. We are using the old 1.x branch which doesn't have this bug.

@demrks
Copy link

demrks commented Mar 9, 2015

I'm still seeing deltaX/deltaY jumps with 2.0.4 (Android Chrome, iOS Safari). If you are panning with one finger and you add another finger later (for multitouch panning, pinching etc.) there are unexpected deltaX/deltaY changes.

EDIT
Here is a simple test (panning and pinching): http://codepen.io/anon/pen/Joaavb
Even if I comment the pinching part there is still deltaXY jumping happening as soon as you try to pan with multiple fingers (Left finger down, Left finger pan, Right finger down (Left finger is still down), Right finger pan etc. ): http://codepen.io/anon/pen/KwxxRL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants