Added direction for PanGesture

This commit is contained in:
Pavel fljot 2012-02-29 13:54:59 +02:00
parent 09dc1ddfc4
commit 3dcc78c267
2 changed files with 18 additions and 2 deletions

View file

@ -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;

View file

@ -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;
}
}