mirror of
https://github.com/scratchfoundation/Gestouch.git
synced 2025-02-17 07:50:14 -05:00
Merge branch 'refs/heads/develop'
This commit is contained in:
commit
04d16fcc56
13 changed files with 233 additions and 230 deletions
17
build.xml
17
build.xml
|
@ -8,7 +8,7 @@
|
|||
<property file="version.properties" />
|
||||
|
||||
|
||||
<target name="release" description="" depends="compile.swc, asdoc">
|
||||
<target name="release" description="" depends="compile.swc, asdoc, fat.swc">
|
||||
<!-- TODO: tests? -->
|
||||
</target>
|
||||
|
||||
|
@ -45,9 +45,9 @@
|
|||
<java jar="${FLEX_HOME}/lib/asdoc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
|
||||
<arg line="-source-path ${src.dir}"/>
|
||||
<arg line="-doc-sources ${src.dir}"/>
|
||||
<arg line="-exclude-classes com.inreflected.utils.pooling.ObjectPool"/>
|
||||
<arg line="-output ${asdoc.dir}"/>
|
||||
<arg value="-keep-xml=true"/>
|
||||
<arg value="-skip-xsl=true"/>
|
||||
<arg line="-window-title 'Gestouch ${project.version}'"/>
|
||||
<arg line="-main-title 'Gestouch ${project.version}'"/>
|
||||
<arg line="-footer 'Gestouch - http://github.com/fljot/Gestouch/ - Documentation generated at: ${docgen.time}'"/>
|
||||
|
@ -56,5 +56,18 @@
|
|||
</java>
|
||||
<echo>[asdoc] ASDOC documentation generated successfully</echo>
|
||||
</target>
|
||||
|
||||
<target name="fat.swc">
|
||||
<echo>[fat.swc] Adding documentation to swc</echo>
|
||||
<!-- updates swc with asdoc xml -->
|
||||
<zip destfile="${binrelease.dir}/gestouch-${project.version}.swc" update="true">
|
||||
<zipfileset dir="${asdoc.dir}/tempdita" prefix="docs">
|
||||
<include name="*.*" />
|
||||
<exclude name="ASDoc_Config.xml" />
|
||||
<exclude name="overviews.xml" />
|
||||
</zipfileset>
|
||||
</zip>
|
||||
<echo>[fat.swc] Documentation added to swc successfully</echo>
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -1,8 +1,7 @@
|
|||
package org.gestouch.core
|
||||
{
|
||||
import com.inreflected.utils.pooling.ObjectPool;
|
||||
|
||||
import org.gestouch.events.MouseTouchEvent;
|
||||
import org.gestouch.utils.ObjectPool;
|
||||
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.display.Stage;
|
||||
|
@ -85,7 +84,7 @@ package org.gestouch.core
|
|||
_stage.addEventListener(MouseEvent.MOUSE_DOWN, stage_mouseDownHandler);
|
||||
_stage.addEventListener(TouchEvent.TOUCH_BEGIN, stage_touchBeginHandler);
|
||||
_stage.addEventListener(TouchEvent.TOUCH_MOVE, stage_touchMoveHandler);
|
||||
_stage.addEventListener(TouchEvent.TOUCH_END, stage_touchEndHandler);
|
||||
_stage.addEventListener(TouchEvent.TOUCH_END, stage_touchEndHandler, true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -168,8 +167,8 @@ package org.gestouch.core
|
|||
|
||||
|
||||
public function updateGestureTarget(gesture:IGesture, oldTarget:InteractiveObject, newTarget:InteractiveObject):void
|
||||
{
|
||||
if (!_initialized)
|
||||
{
|
||||
if (!_initialized && newTarget)
|
||||
{
|
||||
var stage:Stage = newTarget.stage;
|
||||
if (stage)
|
||||
|
@ -188,12 +187,13 @@ package org.gestouch.core
|
|||
{
|
||||
gesturesOfTypeByTarget = _gestureMapsByType[gesture.reflect()] = new Dictionary();
|
||||
}
|
||||
if (gesturesOfTypeByTarget[newTarget])
|
||||
else if (gesturesOfTypeByTarget[newTarget])
|
||||
{
|
||||
throw new IllegalOperationError("You cannot add two gestures of the same type to one target (it makes no sence).");
|
||||
}
|
||||
if (oldTarget)
|
||||
{
|
||||
oldTarget.addEventListener(Event.ADDED_TO_STAGE, target_addedToStageHandler);
|
||||
delete gesturesOfTypeByTarget[oldTarget];
|
||||
}
|
||||
if (newTarget)
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package org.gestouch.core
|
||||
{
|
||||
import flash.events.IEventDispatcher;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.TouchEvent;
|
||||
|
||||
/**
|
||||
* @author Pavel fljot
|
||||
*/
|
||||
public interface IGesture
|
||||
public interface IGesture extends IEventDispatcher
|
||||
{
|
||||
function get target():InteractiveObject;
|
||||
function get trackingPoints():Vector.<TouchPoint>;
|
||||
|
|
32
src/org/gestouch/events/GestureTrackingEvent.as
Normal file
32
src/org/gestouch/events/GestureTrackingEvent.as
Normal file
|
@ -0,0 +1,32 @@
|
|||
package org.gestouch.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
|
||||
/**
|
||||
* @author Pavel fljot
|
||||
*/
|
||||
public class GestureTrackingEvent extends Event
|
||||
{
|
||||
public static const GESTURE_TRACKING_BEGIN:String = "gestureTrackingBegin";
|
||||
public static const GESTURE_TRACKING_END:String = "gestureTrackingEnd";
|
||||
|
||||
|
||||
public function GestureTrackingEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false)
|
||||
{
|
||||
super(type, bubbles, cancelable);
|
||||
}
|
||||
|
||||
|
||||
override public function clone():Event
|
||||
{
|
||||
return new GestureTrackingEvent(type, bubbles, cancelable);
|
||||
}
|
||||
|
||||
|
||||
override public function toString():String
|
||||
{
|
||||
return formatToString("GestureTrackingEvent", "type", "bubbles", "cancelable", "eventPhase");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,20 +1,18 @@
|
|||
package org.gestouch.gestures
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.events.TouchEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.Timer;
|
||||
import org.gestouch.core.GesturesManager;
|
||||
import org.gestouch.core.TouchPoint;
|
||||
import org.gestouch.core.gestouch_internal;
|
||||
import org.gestouch.events.DoubleTapGestureEvent;
|
||||
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.Timer;
|
||||
|
||||
|
||||
|
||||
[Event(name="gestureDoubleTap", type="org.gestouch.events.DoubleTapGestureEvent")]
|
||||
/**
|
||||
* DoubleTapGesture tracks quick double-tap (double-click).
|
||||
*
|
||||
|
@ -70,7 +68,7 @@ package org.gestouch.gestures
|
|||
protected var _lastCentralPoint:Point;
|
||||
|
||||
|
||||
public function DoubleTapGesture(target:InteractiveObject, settings:Object = null)
|
||||
public function DoubleTapGesture(target:InteractiveObject = null, settings:Object = null)
|
||||
{
|
||||
super(target, settings);
|
||||
}
|
||||
|
@ -110,24 +108,6 @@ package org.gestouch.gestures
|
|||
}
|
||||
|
||||
|
||||
override public function shouldTrackPoint(event:TouchEvent, touchPoint:TouchPoint):Boolean
|
||||
{
|
||||
// No need to track more points than we need
|
||||
if (_trackingPointsCount == maxTouchPointsCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// this particular gesture is interested only in those touchpoints on top of target
|
||||
var touchTarget:InteractiveObject = event.target as InteractiveObject;
|
||||
if (touchTarget != target && !(target is DisplayObjectContainer && (target as DisplayObjectContainer).contains(touchTarget)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
override public function onTouchBegin(touchPoint:TouchPoint):void
|
||||
{
|
||||
// No need to track more points than we need
|
||||
|
@ -147,7 +127,7 @@ package org.gestouch.gestures
|
|||
_thresholdTimer.reset();
|
||||
_thresholdTimer.delay = timeThreshold;
|
||||
_thresholdTimer.start();
|
||||
_adjustCentralPoint();
|
||||
_updateCentralPoint();
|
||||
}
|
||||
|
||||
_minTouchPointsCountReached = true;
|
||||
|
@ -155,7 +135,7 @@ package org.gestouch.gestures
|
|||
if (moveThreshold > 0)
|
||||
{
|
||||
// calculate central point for future moveThreshold comparsion
|
||||
_adjustCentralPoint();
|
||||
_updateCentralPoint();
|
||||
// save points for later comparsion with moveThreshold
|
||||
_prevCentralPoint = _lastCentralPoint;
|
||||
_lastCentralPoint = _centralPoint.clone();
|
||||
|
@ -190,17 +170,9 @@ package org.gestouch.gestures
|
|||
{
|
||||
// double tap combo recognized
|
||||
|
||||
if (moveThreshold > 0)
|
||||
{
|
||||
if (_lastCentralPoint.subtract(_prevCentralPoint).length < moveThreshold)
|
||||
{
|
||||
_reset();
|
||||
_dispatch(new DoubleTapGestureEvent(DoubleTapGestureEvent.GESTURE_DOUBLE_TAP, true, false, GesturePhase.ALL, _lastLocalCentralPoint.x, _lastLocalCentralPoint.y));
|
||||
}
|
||||
}
|
||||
else
|
||||
if ((moveThreshold > 0 && _lastCentralPoint.subtract(_prevCentralPoint).length < moveThreshold)
|
||||
|| isNaN(moveThreshold) || moveThreshold <= 0)
|
||||
{
|
||||
// no moveThreshold defined
|
||||
_reset();
|
||||
_dispatch(new DoubleTapGestureEvent(DoubleTapGestureEvent.GESTURE_DOUBLE_TAP, true, false, GesturePhase.ALL, _lastLocalCentralPoint.x, _lastLocalCentralPoint.y));
|
||||
}
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
package org.gestouch.gestures
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.events.TouchEvent;
|
||||
import org.gestouch.core.GesturesManager;
|
||||
import org.gestouch.core.TouchPoint;
|
||||
import org.gestouch.core.gestouch_internal;
|
||||
import org.gestouch.events.DragGestureEvent;
|
||||
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.geom.Point;
|
||||
|
||||
|
||||
|
||||
[Event(name="gestureDrag", type="org.gestouch.events.DragGestureEvent")]
|
||||
/**
|
||||
* Tracks the drag. Event works nice with minTouchPointsCount = 1 and maxTouchPoaintsCount > 1.
|
||||
*
|
||||
|
@ -25,7 +24,7 @@ package org.gestouch.gestures
|
|||
*/
|
||||
public class DragGesture extends MovingGestureBase
|
||||
{
|
||||
public function DragGesture(target:InteractiveObject, settings:Object = null)
|
||||
public function DragGesture(target:InteractiveObject = null, settings:Object = null)
|
||||
{
|
||||
super(target, settings);
|
||||
}
|
||||
|
@ -65,24 +64,6 @@ package org.gestouch.gestures
|
|||
}
|
||||
|
||||
|
||||
override public function shouldTrackPoint(event:TouchEvent, tp:TouchPoint):Boolean
|
||||
{
|
||||
// No need to track more points than we need
|
||||
if (_trackingPointsCount == maxTouchPointsCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// this particular gesture is interested only in those touchpoints on top of target
|
||||
var touchTarget:InteractiveObject = event.target as InteractiveObject;
|
||||
if (touchTarget != target && !(target is DisplayObjectContainer && (target as DisplayObjectContainer).contains(touchTarget)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
override public function onTouchBegin(touchPoint:TouchPoint):void
|
||||
{
|
||||
// No need to track more points than we need
|
||||
|
@ -95,7 +76,7 @@ package org.gestouch.gestures
|
|||
|
||||
if (_trackingPointsCount > 1)
|
||||
{
|
||||
_adjustCentralPoint();
|
||||
_updateCentralPoint();
|
||||
_centralPoint.lastMove.x = _centralPoint.lastMove.y = 0;
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +90,7 @@ package org.gestouch.gestures
|
|||
return;
|
||||
}
|
||||
|
||||
_adjustCentralPoint();
|
||||
_updateCentralPoint();
|
||||
|
||||
if (!_slopPassed)
|
||||
{
|
||||
|
@ -117,12 +98,30 @@ package org.gestouch.gestures
|
|||
|
||||
if (_slopPassed)
|
||||
{
|
||||
_centralPoint.lastMove.x = _centralPoint.lastMove.y = 0;
|
||||
_dispatch(new DragGestureEvent(DragGestureEvent.GESTURE_DRAG, true, false, GesturePhase.BEGIN, _lastLocalCentralPoint.x, _lastLocalCentralPoint.y));
|
||||
var slopVector:Point = slop > 0 ? null : new Point();
|
||||
if (!slopVector)
|
||||
{
|
||||
if (_canMoveHorizontally && _canMoveVertically)
|
||||
{
|
||||
slopVector = _centralPoint.moveOffset.clone();
|
||||
slopVector.normalize(slop);
|
||||
slopVector.x = Math.round(slopVector.x);
|
||||
slopVector.y = Math.round(slopVector.y);
|
||||
}
|
||||
else if (_canMoveVertically)
|
||||
{
|
||||
slopVector = new Point(0, _centralPoint.moveOffset.y >= slop ? slop : -slop);
|
||||
}
|
||||
else if (_canMoveHorizontally)
|
||||
{
|
||||
slopVector = new Point(_centralPoint.moveOffset.x >= slop ? slop : -slop, 0);
|
||||
}
|
||||
}
|
||||
_centralPoint.lastMove = _centralPoint.moveOffset.subtract(slopVector);
|
||||
_dispatch(new DragGestureEvent(DragGestureEvent.GESTURE_DRAG, true, false, GesturePhase.BEGIN, _lastLocalCentralPoint.x, _lastLocalCentralPoint.y, 1, 1, 0, _centralPoint.lastMove.x, _centralPoint.lastMove.y));
|
||||
}
|
||||
}
|
||||
|
||||
if (_slopPassed)
|
||||
else
|
||||
{
|
||||
_dispatch(new DragGestureEvent(DragGestureEvent.GESTURE_DRAG, true, false, GesturePhase.UPDATE, _lastLocalCentralPoint.x, _lastLocalCentralPoint.y, 1, 1, 0, _centralPoint.lastMove.x, _centralPoint.lastMove.y));
|
||||
}
|
||||
|
@ -131,11 +130,10 @@ package org.gestouch.gestures
|
|||
|
||||
override public function onTouchEnd(touchPoint:TouchPoint):void
|
||||
{
|
||||
var ending:Boolean = (_trackingPointsCount == minTouchPointsCount);
|
||||
var ending:Boolean = (_slopPassed && _trackingPointsCount == minTouchPointsCount);
|
||||
_forgetPoint(touchPoint);
|
||||
|
||||
_adjustCentralPoint();
|
||||
_centralPoint.lastMove.x = _centralPoint.lastMove.y = 0;
|
||||
_updateCentralPoint();
|
||||
|
||||
if (ending)
|
||||
{
|
||||
|
|
|
@ -1,25 +1,30 @@
|
|||
package org.gestouch.gestures
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GestureEvent;
|
||||
import flash.events.TouchEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.system.Capabilities;
|
||||
|
||||
import org.gestouch.core.GesturesManager;
|
||||
import org.gestouch.core.IGesture;
|
||||
import org.gestouch.core.TouchPoint;
|
||||
import org.gestouch.core.gestouch_internal;
|
||||
import org.gestouch.events.GestureTrackingEvent;
|
||||
|
||||
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.GestureEvent;
|
||||
import flash.events.TouchEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.system.Capabilities;
|
||||
|
||||
|
||||
[Event(name="gestureTrackingBegin", type="org.gestouch.events.GestureTrackingEvent")]
|
||||
[Event(name="gestureTrackingEnd", type="org.gestouch.events.GestureTrackingEvent")]
|
||||
/**
|
||||
* Base class for all gestures. Gesture is essentially a detector that tracks touch points
|
||||
* in order detect specific gesture motion and form gesture event on target.
|
||||
*
|
||||
* @author Pavel fljot
|
||||
*/
|
||||
public class Gesture implements IGesture
|
||||
public class Gesture extends EventDispatcher implements IGesture
|
||||
{
|
||||
/**
|
||||
* Threshold for screen distance they must move to count as valid input
|
||||
|
@ -41,7 +46,7 @@ package org.gestouch.gestures
|
|||
protected var _lastLocalCentralPoint:Point;
|
||||
|
||||
|
||||
public function Gesture(target:InteractiveObject, settings:Object = null)
|
||||
public function Gesture(target:InteractiveObject = null, settings:Object = null)
|
||||
{
|
||||
// Check if gesture reflects it's class properly
|
||||
reflect();
|
||||
|
@ -126,23 +131,15 @@ package org.gestouch.gestures
|
|||
}
|
||||
public function set target(value:InteractiveObject):void
|
||||
{
|
||||
if (_target == value) return;
|
||||
if (target == value) return;
|
||||
|
||||
GesturesManager.gestouch_internal::updateGestureTarget(this, target, value);
|
||||
|
||||
// if GesturesManager hasn't thrown any error we can safely continue
|
||||
|
||||
if (target)
|
||||
{
|
||||
_uninstallTarget(target);
|
||||
}
|
||||
|
||||
_uninstallTarget(target);
|
||||
_target = value;
|
||||
|
||||
if (target)
|
||||
{
|
||||
_installTarget(target);
|
||||
}
|
||||
_installTarget(target);
|
||||
}
|
||||
|
||||
|
||||
|
@ -214,23 +211,32 @@ package org.gestouch.gestures
|
|||
}
|
||||
|
||||
|
||||
[Abstract]
|
||||
/**
|
||||
* Used by GesturesManager to check wether this gesture is interested in
|
||||
* tracking this touch point upon this event (of type TouchEvent.TOUCH_BEGIN).
|
||||
*
|
||||
* <p>Most of the gestures check, if event.target is target or target contains event.target</p>
|
||||
* <p>Most of the gestures check, if event.target is target or target contains event.target.</p>
|
||||
*
|
||||
* <p>No need to use it directly.</p>
|
||||
*
|
||||
* <p><b>NB!</b> This is abstract method and must be overridden.</p>
|
||||
*
|
||||
* @see org.gestouch.core.GesturesManager
|
||||
* @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/TouchEvent.html
|
||||
*/
|
||||
public function shouldTrackPoint(event:TouchEvent, tp:TouchPoint):Boolean
|
||||
{
|
||||
throw Error("shouldTrackPoint() is abstract method and must be overridden.");
|
||||
// No need to track more points than we need
|
||||
if (_trackingPointsCount == maxTouchPointsCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//By default gesture is interested only in those touchpoints on top of target
|
||||
var touchTarget:InteractiveObject = event.target as InteractiveObject;
|
||||
if (touchTarget != target && !(target is DisplayObjectContainer && (target as DisplayObjectContainer).contains(touchTarget)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -386,14 +392,26 @@ _propertyNames.push("timeThreshold", "moveThreshold");
|
|||
|
||||
|
||||
/**
|
||||
* Dispatches gesture event from the name of target.
|
||||
* Dispatches gesture event on gesture and on target.
|
||||
*
|
||||
* @param event GestureEvent to be dispatched from target
|
||||
* <p>Why dispatching event on gesture? Because it make sense to dispatch event from
|
||||
* detector object (gesture) and we can add [Event] metatag for better autocompletion.</p>
|
||||
*
|
||||
* <p>Why dispatching event on target? Becase it supposed to be like this in
|
||||
* comparsion to native way, and it also make sense as similar to mouse and touch events.</p>
|
||||
*
|
||||
* @param event GestureEvent to be dispatched
|
||||
*
|
||||
* @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/GestureEvent.html
|
||||
*/
|
||||
protected function _dispatch(event:GestureEvent):void
|
||||
{
|
||||
if (hasEventListener(event.type))
|
||||
{
|
||||
dispatchEvent(event);
|
||||
}
|
||||
|
||||
// event is almost always bubbles, so no point for optimization
|
||||
target.dispatchEvent(event);
|
||||
}
|
||||
|
||||
|
@ -434,6 +452,28 @@ _propertyNames.push("timeThreshold", "moveThreshold");
|
|||
_firstTouchPoint = touchPoint;
|
||||
_centralPoint = touchPoint.clone() as TouchPoint;
|
||||
}
|
||||
else if (_trackingPointsCount == minTouchPointsCount)
|
||||
{
|
||||
_updateCentralPoint();
|
||||
_centralPoint.touchBeginPos.x = _centralPoint.x;
|
||||
_centralPoint.touchBeginPos.y = _centralPoint.y;
|
||||
_centralPoint.moveOffset.x = 0;
|
||||
_centralPoint.moveOffset.y = 0;
|
||||
_centralPoint.lastMove.x = 0;
|
||||
_centralPoint.lastMove.y = 0;
|
||||
}
|
||||
else if (_trackingPointsCount > minTouchPointsCount)
|
||||
{
|
||||
_adjustCentralPoint();
|
||||
}
|
||||
|
||||
if (_trackingPointsCount == minTouchPointsCount)
|
||||
{
|
||||
if (hasEventListener(GestureTrackingEvent.GESTURE_TRACKING_BEGIN))
|
||||
{
|
||||
dispatchEvent(new GestureTrackingEvent(GestureTrackingEvent.GESTURE_TRACKING_BEGIN));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -451,11 +491,21 @@ _propertyNames.push("timeThreshold", "moveThreshold");
|
|||
delete _trackingPointsMap[touchPoint.id];
|
||||
_trackingPoints.splice(_trackingPoints.indexOf(touchPoint), 1);
|
||||
_trackingPointsCount--;
|
||||
|
||||
_adjustCentralPoint();
|
||||
|
||||
if (_trackingPointsCount == minTouchPointsCount + 1)
|
||||
{
|
||||
if (hasEventListener(GestureTrackingEvent.GESTURE_TRACKING_END))
|
||||
{
|
||||
dispatchEvent(new GestureTrackingEvent(GestureTrackingEvent.GESTURE_TRACKING_END));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adjusts (recalculates) _centralPoint and all it's properties
|
||||
* Updates _centralPoint and all it's properties
|
||||
* (such as positions, offsets, velocity, etc...).
|
||||
* Also updates _lastLocalCentralPoint (used for dispatching events).
|
||||
*
|
||||
|
@ -463,7 +513,7 @@ _propertyNames.push("timeThreshold", "moveThreshold");
|
|||
* @see #_lastLocalCentralPoint
|
||||
* @see #trackingPoints
|
||||
*/
|
||||
protected function _adjustCentralPoint():void
|
||||
protected function _updateCentralPoint():void
|
||||
{
|
||||
var x:Number = 0;
|
||||
var y:Number = 0;
|
||||
|
@ -495,6 +545,21 @@ _propertyNames.push("timeThreshold", "moveThreshold");
|
|||
|
||||
_lastLocalCentralPoint = target.globalToLocal(_centralPoint);
|
||||
}
|
||||
|
||||
|
||||
protected function _adjustCentralPoint():void
|
||||
{
|
||||
var oldCentralPoint:TouchPoint = _centralPoint.clone() as TouchPoint;
|
||||
_updateCentralPoint();
|
||||
var centralPointChange:Point = _centralPoint.subtract(oldCentralPoint);
|
||||
_centralPoint.touchBeginPos = _centralPoint.touchBeginPos.add(centralPointChange);
|
||||
// fix moveOffset according to fixed touchBeginPos
|
||||
_centralPoint.moveOffset.x = _centralPoint.x - _centralPoint.touchBeginPos.x;
|
||||
_centralPoint.moveOffset.y = _centralPoint.y - _centralPoint.touchBeginPos.y;
|
||||
// restore original lastMove
|
||||
_centralPoint.lastMove.x = oldCentralPoint.lastMove.x;
|
||||
_centralPoint.lastMove.y = oldCentralPoint.lastMove.y;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package org.gestouch.gestures
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.events.TouchEvent;
|
||||
import flash.utils.Timer;
|
||||
import org.gestouch.core.GesturesManager;
|
||||
import org.gestouch.core.TouchPoint;
|
||||
import org.gestouch.core.gestouch_internal;
|
||||
import org.gestouch.events.LongPressGestureEvent;
|
||||
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.utils.Timer;
|
||||
|
||||
|
||||
[Event(name="gestureLongPress", type="org.gestouch.events.LongPressGestureEvent")]
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@ -33,7 +32,7 @@ package org.gestouch.gestures
|
|||
protected var _thresholdTimer:Timer;
|
||||
|
||||
|
||||
public function LongPressGesture(target:InteractiveObject, settings:Object = null)
|
||||
public function LongPressGesture(target:InteractiveObject = null, settings:Object = null)
|
||||
{
|
||||
super(target, settings);
|
||||
}
|
||||
|
@ -73,25 +72,6 @@ package org.gestouch.gestures
|
|||
}
|
||||
|
||||
|
||||
|
||||
override public function shouldTrackPoint(event:TouchEvent, tp:TouchPoint):Boolean
|
||||
{
|
||||
// No need to track more points than we need
|
||||
if (_trackingPointsCount == maxTouchPointsCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// this particular gesture is interested only in those touchpoints on top of target
|
||||
var touchTarget:InteractiveObject = event.target as InteractiveObject;
|
||||
if (touchTarget != target && !(target is DisplayObjectContainer && (target as DisplayObjectContainer).contains(touchTarget)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
override public function onTouchBegin(touchPoint:TouchPoint):void
|
||||
{
|
||||
// No need to track more points than we need
|
||||
|
@ -133,7 +113,7 @@ package org.gestouch.gestures
|
|||
|
||||
if (held)
|
||||
{
|
||||
_adjustCentralPoint();
|
||||
_updateCentralPoint();
|
||||
_reset();
|
||||
_dispatch(new LongPressGestureEvent(LongPressGestureEvent.GESTURE_LONG_PRESS, true, false, GesturePhase.END, _lastLocalCentralPoint.x, _lastLocalCentralPoint.y));
|
||||
}
|
||||
|
@ -177,7 +157,7 @@ package org.gestouch.gestures
|
|||
|
||||
protected function _onThresholdTimerComplete(event:TimerEvent):void
|
||||
{
|
||||
_adjustCentralPoint();
|
||||
_updateCentralPoint();
|
||||
_dispatch(new LongPressGestureEvent(LongPressGestureEvent.GESTURE_LONG_PRESS, true, false, GesturePhase.BEGIN, _lastLocalCentralPoint.x, _lastLocalCentralPoint.y));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ package org.gestouch.gestures
|
|||
protected var _canMoveVertically:Boolean = true;
|
||||
|
||||
|
||||
public function MovingGestureBase(target:InteractiveObject, settings:Object = null)
|
||||
public function MovingGestureBase(target:InteractiveObject = null, settings:Object = null)
|
||||
{
|
||||
super(target, settings);
|
||||
|
||||
|
@ -131,6 +131,11 @@ package org.gestouch.gestures
|
|||
protected function _checkSlop(moveDelta:Point):Boolean
|
||||
{
|
||||
var slopPassed:Boolean = false;
|
||||
if (!(slop > 0))
|
||||
{
|
||||
// return true immideately if slop is 0 or NaN
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_canMoveHorizontally && _canMoveVertically)
|
||||
{
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package org.gestouch.gestures
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.events.TouchEvent;
|
||||
import flash.geom.Point;
|
||||
import org.gestouch.GestureUtils;
|
||||
import org.gestouch.core.GesturesManager;
|
||||
import org.gestouch.core.TouchPoint;
|
||||
import org.gestouch.core.gestouch_internal;
|
||||
import org.gestouch.events.RotateGestureEvent;
|
||||
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.geom.Point;
|
||||
|
||||
|
||||
[Event(name="gestureRotate", type="org.gestouch.events.RotateGestureEvent")]
|
||||
/**
|
||||
* @author Pavel fljot
|
||||
*/
|
||||
|
@ -37,7 +36,7 @@ package org.gestouch.gestures
|
|||
//
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
public static function add(target:InteractiveObject, settings:Object = null):RotateGesture
|
||||
public static function add(target:InteractiveObject = null, settings:Object = null):RotateGesture
|
||||
{
|
||||
return new RotateGesture(target, settings);
|
||||
}
|
||||
|
@ -70,25 +69,6 @@ package org.gestouch.gestures
|
|||
return RotateGesture;
|
||||
}
|
||||
|
||||
|
||||
override public function shouldTrackPoint(event:TouchEvent, tp:TouchPoint):Boolean
|
||||
{
|
||||
// No need to track more points than we need
|
||||
if (_trackingPointsCount == maxTouchPointsCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// this particular gesture is interested only in those touchpoints on top of target
|
||||
//FIXME?
|
||||
var touchTarget:InteractiveObject = event.target as InteractiveObject;
|
||||
if (touchTarget != target && !(target is DisplayObjectContainer && (target as DisplayObjectContainer).contains(touchTarget)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
override public function onTouchBegin(touchPoint:TouchPoint):void
|
||||
{
|
||||
|
@ -105,7 +85,7 @@ package org.gestouch.gestures
|
|||
_lastVector.x = _trackingPoints[1].x - _trackingPoints[0].x;
|
||||
_lastVector.y = _trackingPoints[1].y - _trackingPoints[0].y;
|
||||
|
||||
_adjustCentralPoint();
|
||||
_updateCentralPoint();
|
||||
|
||||
_dispatch(new RotateGestureEvent(RotateGestureEvent.GESTURE_ROTATE, true, false, GesturePhase.BEGIN, _lastLocalCentralPoint.x, _lastLocalCentralPoint.y));
|
||||
}
|
||||
|
@ -120,7 +100,7 @@ package org.gestouch.gestures
|
|||
return;
|
||||
}
|
||||
|
||||
_adjustCentralPoint();
|
||||
_updateCentralPoint();
|
||||
|
||||
_currVector.x = _trackingPoints[1].x - _trackingPoints[0].x;
|
||||
_currVector.y = _trackingPoints[1].y - _trackingPoints[0].y;
|
||||
|
@ -128,16 +108,12 @@ package org.gestouch.gestures
|
|||
var a1:Number = Math.atan2(_lastVector.y, _lastVector.x);
|
||||
var a2:Number = Math.atan2(_currVector.y, _currVector.x);
|
||||
var angle:Number = a2 - a1;
|
||||
if (angle < 0)
|
||||
{
|
||||
angle += GestureUtils.PI_DOUBLE;
|
||||
}
|
||||
angle *= GestureUtils.RADIANS_TO_DEGREES;
|
||||
|
||||
_dispatch(new RotateGestureEvent(RotateGestureEvent.GESTURE_ROTATE, true, false, GesturePhase.UPDATE, _lastLocalCentralPoint.x, _lastLocalCentralPoint.y, 1, 1, angle));
|
||||
|
||||
_lastVector.x = _currVector.x;
|
||||
_lastVector.y = _currVector.y;
|
||||
|
||||
_dispatch(new RotateGestureEvent(RotateGestureEvent.GESTURE_ROTATE, true, false, GesturePhase.UPDATE, _lastLocalCentralPoint.x, _lastLocalCentralPoint.y, 1, 1, angle));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package org.gestouch.gestures
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.events.TouchEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.getTimer;
|
||||
|
||||
import org.gestouch.Direction;
|
||||
import org.gestouch.GestureUtils;
|
||||
import org.gestouch.core.GesturesManager;
|
||||
|
@ -14,7 +7,13 @@ package org.gestouch.gestures
|
|||
import org.gestouch.core.gestouch_internal;
|
||||
import org.gestouch.events.SwipeGestureEvent;
|
||||
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.getTimer;
|
||||
|
||||
|
||||
[Event(name="gestureSwipe", type="org.gestouch.events.SwipeGestureEvent")]
|
||||
/**
|
||||
* SwipeGesture detects <i>swipe</i> motion (also known as <i>flick</i> or <i>flig</i>).
|
||||
*
|
||||
|
@ -35,7 +34,7 @@ package org.gestouch.gestures
|
|||
protected var _startTime:uint;
|
||||
|
||||
|
||||
public function SwipeGesture(target:InteractiveObject, settings:Object = null)
|
||||
public function SwipeGesture(target:InteractiveObject = null, settings:Object = null)
|
||||
{
|
||||
super(target, settings);
|
||||
}
|
||||
|
@ -74,24 +73,6 @@ package org.gestouch.gestures
|
|||
return SwipeGesture;
|
||||
}
|
||||
|
||||
|
||||
override public function shouldTrackPoint(event:TouchEvent, tp:TouchPoint):Boolean
|
||||
{
|
||||
// No need to track more points than we need
|
||||
if (_trackingPointsCount == maxTouchPointsCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// this particular gesture is interested only in those touchpoints on top of target
|
||||
var touchTarget:InteractiveObject = event.target as InteractiveObject;
|
||||
if (touchTarget != target && !(target is DisplayObjectContainer && (target as DisplayObjectContainer).contains(touchTarget)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
override public function onTouchBegin(touchPoint:TouchPoint):void
|
||||
{
|
||||
|
@ -113,7 +94,7 @@ package org.gestouch.gestures
|
|||
return;
|
||||
}
|
||||
|
||||
_adjustCentralPoint();
|
||||
_updateCentralPoint();
|
||||
|
||||
if (!_slopPassed)
|
||||
{
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
package org.gestouch.gestures
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.events.TouchEvent;
|
||||
import flash.geom.Point;
|
||||
import org.gestouch.core.GesturesManager;
|
||||
import org.gestouch.core.TouchPoint;
|
||||
import org.gestouch.core.gestouch_internal;
|
||||
import org.gestouch.events.ZoomGestureEvent;
|
||||
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.events.GesturePhase;
|
||||
import flash.geom.Point;
|
||||
|
||||
|
||||
[Event(name="gestureZoom", type="org.gestouch.events.ZoomGestureEvent")]
|
||||
/**
|
||||
* @author Pavel fljot
|
||||
*/
|
||||
|
@ -37,7 +36,7 @@ package org.gestouch.gestures
|
|||
//
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
public static function add(target:InteractiveObject, settings:Object = null):ZoomGesture
|
||||
public static function add(target:InteractiveObject = null, settings:Object = null):ZoomGesture
|
||||
{
|
||||
return new ZoomGesture(target, settings);
|
||||
}
|
||||
|
@ -62,25 +61,6 @@ package org.gestouch.gestures
|
|||
return ZoomGesture;
|
||||
}
|
||||
|
||||
|
||||
override public function shouldTrackPoint(event:TouchEvent, tp:TouchPoint):Boolean
|
||||
{
|
||||
// No need to track more points than we need
|
||||
if (_trackingPointsCount == maxTouchPointsCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// this particular gesture is interested only in those touchpoints on top of target
|
||||
//FIXME?
|
||||
var touchTarget:InteractiveObject = event.target as InteractiveObject;
|
||||
if (touchTarget != target && !(target is DisplayObjectContainer && (target as DisplayObjectContainer).contains(touchTarget)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
override public function onTouchBegin(touchPoint:TouchPoint):void
|
||||
{
|
||||
|
@ -97,7 +77,7 @@ package org.gestouch.gestures
|
|||
_lastVector.x = _trackingPoints[1].x - _trackingPoints[0].x;
|
||||
_lastVector.y = _trackingPoints[1].y - _trackingPoints[0].y;
|
||||
|
||||
_adjustCentralPoint();
|
||||
_updateCentralPoint();
|
||||
|
||||
_dispatch(new ZoomGestureEvent(ZoomGestureEvent.GESTURE_ZOOM, true, false, GesturePhase.BEGIN, _lastLocalCentralPoint.x, _lastLocalCentralPoint.y));
|
||||
}
|
||||
|
@ -112,7 +92,7 @@ package org.gestouch.gestures
|
|||
return;
|
||||
}
|
||||
|
||||
_adjustCentralPoint();
|
||||
_updateCentralPoint();
|
||||
|
||||
_currVector.x = _trackingPoints[1].x - _trackingPoints[0].x;
|
||||
_currVector.y = _trackingPoints[1].y - _trackingPoints[0].y;
|
||||
|
@ -129,10 +109,10 @@ package org.gestouch.gestures
|
|||
scaleY = _currVector.y / _lastVector.y;
|
||||
}
|
||||
|
||||
_dispatch(new ZoomGestureEvent(ZoomGestureEvent.GESTURE_ZOOM, true, false, GesturePhase.UPDATE, _lastLocalCentralPoint.x, _lastLocalCentralPoint.y, scaleX, scaleY));
|
||||
|
||||
_lastVector.x = _currVector.x;
|
||||
_lastVector.y = _currVector.y;
|
||||
|
||||
_dispatch(new ZoomGestureEvent(ZoomGestureEvent.GESTURE_ZOOM, true, false, GesturePhase.UPDATE, _lastLocalCentralPoint.x, _lastLocalCentralPoint.y, scaleX, scaleY));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.inreflected.utils.pooling
|
||||
package org.gestouch.utils
|
||||
{
|
||||
import flash.utils.getQualifiedClassName;
|
||||
|
Loading…
Reference in a new issue