mirror of
https://github.com/scratchfoundation/Gestouch.git
synced 2024-11-27 01:35:40 -05:00
Improve internal algorithm for TapGesture
This commit is contained in:
parent
ed2efc1954
commit
c5f91e6de1
1 changed files with 6 additions and 8 deletions
|
@ -14,7 +14,6 @@ package org.gestouch.gestures
|
||||||
*/
|
*/
|
||||||
[Event(name="gestureTap", type="org.gestouch.events.TapGestureEvent")]
|
[Event(name="gestureTap", type="org.gestouch.events.TapGestureEvent")]
|
||||||
/**
|
/**
|
||||||
* TODO: check failing conditions (iDevice)
|
|
||||||
*
|
*
|
||||||
* @author Pavel fljot
|
* @author Pavel fljot
|
||||||
*/
|
*/
|
||||||
|
@ -22,7 +21,7 @@ package org.gestouch.gestures
|
||||||
{
|
{
|
||||||
public var numTouchesRequired:uint = 1;
|
public var numTouchesRequired:uint = 1;
|
||||||
public var numTapsRequired:uint = 1;
|
public var numTapsRequired:uint = 1;
|
||||||
public var slop:Number = Gesture.DEFAULT_SLOP;
|
public var slop:Number = Gesture.DEFAULT_SLOP << 2;//iOS has 45px for 132 dpi screen
|
||||||
public var maxTapDelay:uint = 400;
|
public var maxTapDelay:uint = 400;
|
||||||
public var maxTapDuration:uint = 1500;
|
public var maxTapDuration:uint = 1500;
|
||||||
|
|
||||||
|
@ -50,17 +49,17 @@ package org.gestouch.gestures
|
||||||
return TapGesture;
|
return TapGesture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override public function reset():void
|
override public function reset():void
|
||||||
{
|
{
|
||||||
_numTouchesRequiredReached = false;
|
_numTouchesRequiredReached = false;
|
||||||
_tapCounter = 0;
|
_tapCounter = 0;
|
||||||
_timer.reset();
|
_timer.reset();
|
||||||
|
|
||||||
super.reset();
|
super.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override public function canPreventGesture(preventedGesture:Gesture):Boolean
|
override public function canPreventGesture(preventedGesture:Gesture):Boolean
|
||||||
{
|
{
|
||||||
if (preventedGesture is TapGesture &&
|
if (preventedGesture is TapGesture &&
|
||||||
|
@ -106,8 +105,8 @@ package org.gestouch.gestures
|
||||||
|
|
||||||
if (touchesCount == numTouchesRequired)
|
if (touchesCount == numTouchesRequired)
|
||||||
{
|
{
|
||||||
_numTouchesRequiredReached = true;
|
_numTouchesRequiredReached = true;
|
||||||
updateLocation();
|
updateLocation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +124,6 @@ package org.gestouch.gestures
|
||||||
{
|
{
|
||||||
if (!_numTouchesRequiredReached)
|
if (!_numTouchesRequiredReached)
|
||||||
{
|
{
|
||||||
//TODO: check this condition on iDevice
|
|
||||||
setState(GestureState.FAILED);
|
setState(GestureState.FAILED);
|
||||||
}
|
}
|
||||||
else if (touchesCount == 0)
|
else if (touchesCount == 0)
|
||||||
|
|
Loading…
Reference in a new issue