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

offsetdirection returns the opposite direction #639

Closed
annam opened this issue Aug 8, 2014 · 1 comment
Closed

offsetdirection returns the opposite direction #639

annam opened this issue Aug 8, 2014 · 1 comment

Comments

@annam
Copy link
Contributor

annam commented Aug 8, 2014

Hi Jorik,

from my understanding of the docs:
offsetDirection: Direction moved from it's starting point. Matches the DIRECTION constants.

offsetDirection should return the overall direction that we have moved/swiped

eg if i've panned 100px to the left and then 50px to the right, while direction should return right, the offsetdirection should return left.

more importantly and a simpler test case, if i've panned 100px to the left then both direction and offsetdirection should return left. offsetdirection in this case returns right.

in fact, looking at the code it seems that the direction test is reversed:
function getDirection(x, y) {
return x > 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
}

if x is negative then the direction should be left, not the other way around.

then, it seems that the simple direction check is wrong:

function computeIntervalInputData(session, input) {
var deltaX = last.deltaX - input.deltaX;
var deltaY = last.deltaY - input.deltaY;
direction = getDirection(deltaX, deltaY);
}

deltaX should be calculated as input.deltaX - last.deltaX (so that if we've moved to the left, this will return to a negative value).

changing both this and the direction test above should return the correct direction for both direction and offset direction

@runspired
Copy link
Contributor

Closing in favor of #806 and #728

arschmitz pushed a commit that referenced this issue Aug 8, 2015
if after pinch/rotate, one finger touchends before the other, swipe is
incorrectly triggered because the last gesture is a single-touch
gesture. this checked for maximum pointers in gesture

Fixes #640
Ref #639
Ref #806
Closes #669
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants