mirror of
https://github.com/scratchfoundation/Gestouch.git
synced 2025-02-16 23:40:14 -05:00
Improved early failing strategy implementation
as in iOS UIGestureRecognizers. Also fixes bugs with new validating state machine.
This commit is contained in:
parent
6273cc33e6
commit
2e02b13581
8 changed files with 21 additions and 22 deletions
|
@ -367,6 +367,19 @@ package org.gestouch.gestures
|
|||
}
|
||||
|
||||
|
||||
protected function failOrIgnoreTouch(touch:Touch):void
|
||||
{
|
||||
if (state == GestureState.POSSIBLE)
|
||||
{
|
||||
setState(GestureState.FAILED);
|
||||
}
|
||||
else if (state != GestureState.IDLE)
|
||||
{
|
||||
ignoreTouch(touch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Abstract]
|
||||
/**
|
||||
* <p><b>NB!</b> This is abstract method and must be overridden.</p>
|
||||
|
|
|
@ -84,14 +84,7 @@ package org.gestouch.gestures
|
|||
{
|
||||
if (touchesCount > numTouchesRequired)
|
||||
{
|
||||
if (state == GestureState.BEGAN || state == GestureState.CHANGED)
|
||||
{
|
||||
ignoreTouch(touch);
|
||||
}
|
||||
else
|
||||
{
|
||||
setState(GestureState.FAILED);
|
||||
}
|
||||
failOrIgnoreTouch(touch);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,15 +116,14 @@ package org.gestouch.gestures
|
|||
{
|
||||
if (touchesCount > maxNumTouchesRequired)
|
||||
{
|
||||
//TODO
|
||||
ignoreTouch(touch);
|
||||
failOrIgnoreTouch(touch);
|
||||
return;
|
||||
}
|
||||
|
||||
if (touchesCount >= minNumTouchesRequired)
|
||||
{
|
||||
updateLocation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -60,8 +60,7 @@ package org.gestouch.gestures
|
|||
{
|
||||
if (touchesCount > 2)
|
||||
{
|
||||
//TODO
|
||||
ignoreTouch(touch);
|
||||
failOrIgnoreTouch(touch);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,8 +78,7 @@ package org.gestouch.gestures
|
|||
{
|
||||
if (touchesCount > numTouchesRequired)
|
||||
{
|
||||
//TODO: or ignore?
|
||||
setState(GestureState.FAILED);
|
||||
failOrIgnoreTouch(touch);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -93,9 +93,7 @@ package org.gestouch.gestures
|
|||
{
|
||||
if (touchesCount > numTouchesRequired)
|
||||
{
|
||||
// We put more fingers then required at the same time,
|
||||
// so treat that as failed
|
||||
setState(GestureState.FAILED);
|
||||
failOrIgnoreTouch(touch);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,8 +66,7 @@ package org.gestouch.gestures
|
|||
{
|
||||
if (touchesCount > 2)
|
||||
{
|
||||
//TODO: to ignore or to keep this touch somewhere?
|
||||
ignoreTouch(touch);
|
||||
failOrIgnoreTouch(touch);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,8 +60,7 @@ package org.gestouch.gestures
|
|||
{
|
||||
if (touchesCount > 2)
|
||||
{
|
||||
//TODO
|
||||
ignoreTouch(touch);
|
||||
failOrIgnoreTouch(touch);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue