Skip to content

Commit

Permalink
getDirection returns reversed direction
Browse files Browse the repository at this point in the history
if horizontal direction is negative, it should return “Left”, not
“Right”.

this resulted in direction and offsetDirection properties to have
opposite values
  • Loading branch information
annam authored and arschmitz committed Aug 8, 2015
1 parent c46cbba commit e40dcde
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/input.js
Expand Up @@ -220,8 +220,8 @@ function computeIntervalInputData(session, input) {
velocity, velocityX, velocityY, direction;

if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
var deltaX = last.deltaX - input.deltaX;
var deltaY = last.deltaY - input.deltaY;
var deltaX = input.deltaX - last.deltaX;
var deltaY = input.deltaY - last.deltaY;

var v = getVelocity(deltaTime, deltaX, deltaY);
velocityX = v.x;
Expand Down Expand Up @@ -326,9 +326,9 @@ function getDirection(x, y) {
}

if (abs(x) >= abs(y)) {
return x > 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
}
return y > 0 ? DIRECTION_UP : DIRECTION_DOWN;
return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
}

/**
Expand Down

0 comments on commit e40dcde

Please sign in to comment.