Permalink
Browse files

getDirection returns reversed direction

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 Sep 17, 2014
1 parent c46cbba commit e40dcde43bdac7a74c8ce5c05a4f62121089cd91
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/input.js
View
@@ -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;
@@ -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;
}
/**

0 comments on commit e40dcde

Please sign in to comment.