}
}
@Override
public void onTouchMove(TouchMoveEvent event) {
Touch touch = event.getTouches().get(0);
switch (state) {
case INVALID:
break;
case READY:
// WTF?
state = State.INVALID;
break;
case FINDER_DOWN:
// log(" X: " + touch.getPageX() + " old: " + touchStart.getPageX() + " test: " + x);
if (Math.abs(touch.getPageX() - x) >= threshold) {
state = State.FOUND_DIRECTION;
direction = touch.getPageX() - x > 0 ? DIRECTION.LEFT_TO_RIGHT : DIRECTION.RIGHT_TO_LEFT;
SwipeStartEvent swipeStartEvent =
new SwipeStartEvent(TouchCopy.copy(touch), touch.getPageX() - x, direction);
getEventPropagator().fireEvent(source, swipeStartEvent);
} else {
if (Math.abs(touch.getPageY() - y) >= threshold) {
state = State.FOUND_DIRECTION;
direction = touch.getPageY() - y > 0 ? DIRECTION.TOP_TO_BOTTOM : DIRECTION.BOTTOM_TO_TOP;
SwipeStartEvent swipeStartEvent =
new SwipeStartEvent(TouchCopy.copy(touch), touch.getPageY() - y, direction);
getEventPropagator().fireEvent(source, swipeStartEvent);
}
}
break;
case FOUND_DIRECTION:
switch (direction) {
case TOP_TO_BOTTOM:
case BOTTOM_TO_TOP:
lastDistance = Math.abs(touch.getPageY() - y);
getEventPropagator().fireEvent(
source,
new SwipeMoveEvent(TouchCopy.copy(touch), lastDistance > minDistance,
lastDistance, direction));
break;
case LEFT_TO_RIGHT:
case RIGHT_TO_LEFT:
lastDistance = Math.abs(touch.getPageX() - x);
getEventPropagator().fireEvent(
source,
new SwipeMoveEvent(TouchCopy.copy(touch), lastDistance > minDistance,
lastDistance, direction));