mirror of
https://github.com/scratchfoundation/Gestouch.git
synced 2024-11-27 01:35:40 -05:00
Added direction for PanGesture
This commit is contained in:
parent
09dc1ddfc4
commit
3dcc78c267
2 changed files with 18 additions and 2 deletions
|
@ -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;
|
||||
|
|
12
src/org/gestouch/gestures/PanGestureDirection.as
Normal file
12
src/org/gestouch/gestures/PanGestureDirection.as
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue