diff --git a/src/org/gestouch/gestures/PanGesture.as b/src/org/gestouch/gestures/PanGesture.as index d11e47e..c89eac3 100644 --- a/src/org/gestouch/gestures/PanGesture.as +++ b/src/org/gestouch/gestures/PanGesture.as @@ -19,6 +19,10 @@ package org.gestouch.gestures public class PanGesture extends Gesture { public var slop:Number = Gesture.DEFAULT_SLOP; + /** + * Used for initial slop overcome calculations only. + */ + public var direction:uint = PanGestureDirection.NO_DIRECTION; protected var _touchBeginX:Array = []; protected var _touchBeginY:Array = []; @@ -137,8 +141,8 @@ package org.gestouch.gestures if (state == GestureState.POSSIBLE) { // Check if finger moved enough for gesture to be recognized - var dx:Number = Number(_touchBeginX[touch.id]) - touch.x; - var dy:Number = Number(_touchBeginY[touch.id]) - touch.y; + var dx:Number = (direction == PanGestureDirection.VERTICAL) ? 0 : Number(_touchBeginX[touch.id]) - touch.x; + var dy:Number = (direction == PanGestureDirection.HORIZONTAL) ? 0 : Number(_touchBeginY[touch.id]) - touch.y; if (Math.sqrt(dx*dx + dy*dy) > slop || slop != slop)//faster isNaN(slop) { prevLocationX = _location.x; diff --git a/src/org/gestouch/gestures/PanGestureDirection.as b/src/org/gestouch/gestures/PanGestureDirection.as new file mode 100644 index 0000000..8925601 --- /dev/null +++ b/src/org/gestouch/gestures/PanGestureDirection.as @@ -0,0 +1,12 @@ +package org.gestouch.gestures +{ + /** + * @author Pavel fljot + */ + public class PanGestureDirection + { + public static const NO_DIRECTION:uint = 0; + public static const VERTICAL:uint = 1 << 0; + public static const HORIZONTAL:uint = 1 << 1; + } +} \ No newline at end of file