Comments (20)
No swipe gesture is used in touch scrolling with snapping (paging). It's just pan + velocity and offsets. In iOS.. and pretty much sure in Android (that's a mess).
Are you really doing something better than https://github.com/fljot/TouchScrolling/blob/features/decoupled-architecture/src/com/inreflected/ui/touchScroll/TouchScrollModel.as (NB! not finished) ?
from gestouch.
Ah, that's what I was starting to think. We'll check out the TouchScrollModel next! We're still having trouble loading your examples folders into Flash Builder. What project type is recommended: Flex Mobile? Actionscript Mobile?
Thanks, fljot. Keep up the great work!
from gestouch.
While working on velocity calculations we're noticing that pan.offsetX and pan.offsetY are returning 0 on every other
GESTURE_CHANGED events. You can see what I mean from the trace output in our onPan() method:
offset: 0, 0
offset: 3, 3
offset: 0, 0
offset: 1, 0
offset: 0, 0
offset: 4, 4
offset: 0, 0
offset: 2, 0
offset: 0, 0
offset: 0, 1
offset: 0, 0
offset: 0, 2
offset: 0, 0
Is this the intended behavior? We're still working from your "Gestouch-slop-hotfix" branch.
from gestouch.
No, this is definitely not intended behavior. Offset should always have some "length", otherwise it's not really a "change". I encourage you to investigate it =) Are you sure this event handler is for single gesture only and you are actually getting the offset from that gesture?
from gestouch.
Yes, it's very basic and shouldn't have interference from anything else. We even created a test in the root of our Starling project and removed any content besides the stage:
Main Class Initialization
Gestouch.inputAdapter ||= new NativeInputAdapter(stage);
Gestouch.addDisplayListAdapter(DisplayObject, new StarlingDisplayListAdapter());
Gestouch.addTouchHitTester(new StarlingTouchHitTester(star), -1);
Starling "Game" class
var pan:PanGesture = new PanGesture(stage);
pan.slop = 5;
pan.addEventListener(GestureEvent.GESTURE_CHANGED, onPan);
protected function onPan(e:GestureEvent):void {
trace(pan.offsetX + ", " + pan.offsetY); // 0, 0
}
We see the same result using the 0.4.3 SWC as well as the 'Gestouch-slop-hotfix' branch. If the PanGesture is designed to return decimals, we're only getting INTs. I'm wondering if something is rounding or zeroing the offsets out.
from gestouch.
It's only one place where setState(GestureState.CHANGED)
is used in PanGesture, so I think you should trace the sh*t out of there.
Random questions:
Does pan.location actually changes every time?
One touch on the screen only?
from gestouch.
pan.location SHOULD change everytime...we're touching an and object and then dragging it around in a circle as smoothly as possible. Some zeros are definitely natural, but pan is returning them literally every other cycle.
There is only one touch, one gesture listener, one gesture of any kind (hence why we removed our custom Starling code just to be sure).
We've got traces throughout PanGesture.as and Gesture.as. Here's a tracelog from our circular drag motion:
Gesture.as touchLocation: (x=420, y=367) centralPoint: (x=420, y=367)
_offsetX: -9 offsetY: 8
Gesture.as touchLocation: (x=420, y=367) centralPoint: (x=420, y=367)
_offsetX: 0 offsetY: 0
Gesture.as touchLocation: (x=418, y=371) centralPoint: (x=418, y=371)
_offsetX: -2 offsetY: 4
Gesture.as touchLocation: (x=418, y=371) centralPoint: (x=418, y=371)
_offsetX: 0 offsetY: 0
Gesture.as touchLocation: (x=418, y=374) centralPoint: (x=418, y=374)
_offsetX: 0 offsetY: 3
Gesture.as touchLocation: (x=418, y=374) centralPoint: (x=418, y=374)
_offsetX: 0 offsetY: 0
Gesture.as touchLocation: (x=418, y=378) centralPoint: (x=418, y=378)
_offsetX: 0 offsetY: 4
Gesture.as touchLocation: (x=418, y=378) centralPoint: (x=418, y=378)
_offsetX: 0 offsetY: 0
Gesture.as touchLocation: (x=418, y=379) centralPoint: (x=418, y=379)
_offsetX: 0 offsetY: 1
Gesture.as touchLocation: (x=418, y=379) centralPoint: (x=418, y=379)
_offsetX: 0 offsetY: 0
Obviously, the offsets are 0 because touchLocation and centralPoint are the same, but I'm trying to figure out what is happening to the prevLocationX and prevLocationY values because, as you said, they have to be different during a CHANGE event.
from gestouch.
In the PanGesture.as onTouchMove() the updateLocation() call near line 165 returns the same value for _location so the offsets are calculated as 0. I can't notice anything immediately wrong with how the methods work, but maybe the values are being updated before the difference calculation occurs?
from gestouch.
Like if touchMove(...)
is executed twice per actual movement... Are touch.time
and touch.location
also the same in touchMove(...)
?
from gestouch.
Wow, maybe so. Some of the cycles do have the same time and it seems to correlate to when the offsets are 0:
onTouchMove: 382, 473 location: (x=366, y=473) touch.time: 2261 touch location: (x=366, y=473)
_offsetX: -16 offsetY: 0
onTouchMove: 366, 473 location: (x=366, y=473) touch.time: 2261 touch location: (x=366, y=473)
_offsetX: 0 offsetY: 0
onTouchMove: 366, 473 location: (x=357, y=474) touch.time: 2278 touch location: (x=357, y=474)
_offsetX: -9 offsetY: 1
onTouchMove: 357, 474 location: (x=357, y=474) touch.time: 2278 touch location: (x=357, y=474)
_offsetX: 0 offsetY: 0
onTouchMove: 357, 474 location: (x=354, y=475) touch.time: 2294 touch location: (x=354, y=475)
_offsetX: -3 offsetY: 1
onTouchMove: 354, 475 location: (x=354, y=475) touch.time: 2294 touch location: (x=354, y=475)
_offsetX: 0 offsetY: 0
onTouchMove: 354, 475 location: (x=352, y=476) touch.time: 2311 touch location: (x=352, y=476)
_offsetX: -2 offsetY: 1
onTouchMove: 352, 476 location: (x=352, y=476) touch.time: 2311 touch location: (x=352, y=476)
_offsetX: 0 offsetY: 0
from gestouch.
In GesturesManager#onTouchMove(...)
add some traces before and after the cycle to see if it actually makes one or two calls on gesture (that would be weird and very surprising!).
from gestouch.
They have the same time stamps, but I'm not sure if that signifies a repetitious call:
GestureManager.as onTouchMove Touch [id: 0, location: (x=396, y=323), ...] time: 2877
onTouchMove: 400, 328 location: (x=396, y=323) touch.time: 2877 touch location: (x=396, y=323)
_offsetX: -4 offsetY: -5
GestureManager.as onTouchMove Touch [id: 0, location: (x=396, y=323), ...] time: 2878
onTouchMove: 396, 323 location: (x=396, y=323) touch.time: 2878 touch location: (x=396, y=323)
_offsetX: 0 offsetY: 0
GestureManager.as onTouchMove Touch [id: 0, location: (x=386, y=315), ...] time: 2894
onTouchMove: 396, 323 location: (x=386, y=315) touch.time: 2894 touch location: (x=386, y=315)
_offsetX: -10 offsetY: -8
GestureManager.as onTouchMove Touch [id: 0, location: (x=386, y=315), ...] time: 2894
onTouchMove: 386, 315 location: (x=386, y=315) touch.time: 2894 touch location: (x=386, y=315)
_offsetX: 0 offsetY: 0
GestureManager.as onTouchMove Touch [id: 0, location: (x=301, y=292), ...] time: 2911
onTouchMove: 386, 315 location: (x=301, y=292) touch.time: 2911 touch location: (x=301, y=292)
_offsetX: -85 offsetY: -23
GestureManager.as onTouchMove Touch [id: 0, location: (x=301, y=292), ...] time: 2911
onTouchMove: 301, 292 location: (x=301, y=292) touch.time: 2911 touch location: (x=301, y=292)
_offsetX: 0 offsetY: 0
GestureManager.as onTouchMove Touch [id: 0, location: (x=291, y=292), ...] time: 2927
onTouchMove: 301, 292 location: (x=291, y=292) touch.time: 2927 touch location: (x=291, y=292)
_offsetX: -10 offsetY: 0
GestureManager.as onTouchMove Touch [id: 0, location: (x=291, y=292), ...] time: 2927
onTouchMove: 291, 292 location: (x=291, y=292) touch.time: 2927 touch location: (x=291, y=292)
_offsetX: 0 offsetY: 0
Here is the GestureManager.as with trace:
gestouch_internal function onTouchMove(touch:Touch):void
{
var gesturesForTouch:Vector.<Gesture> = _gesturesForTouchMap[touch] as Vector.<Gesture>;
var gesture:Gesture;
var i:uint = gesturesForTouch.length;
while (i-- > 0)
{
gesture = gesturesForTouch[i];
if (!_dirtyGesturesMap[gesture] && gesture.isTrackingTouch(touch.id))
{
trace("GestureManager.as onTouchMove "+touch+" time: " +touch.time);
gesture.touchMoveHandler(touch);
}
else
{
// gesture is no more interested in this touch (e.g. ignoreTouch was called)
gesturesForTouch.splice(i, 1);
}
}
}
from gestouch.
I hope this is helpful. We don't want to get too deep and try debugging your work because we'd probably do more harm than good =)
from gestouch.
No, you got me wrong. Trace before while and after while, this way we can see if gesture call is triggered twice per cycle (which should not happen normally).
from gestouch.
Got it. Is this what you're looking for? There are still duplicates on every other call (signified between the trace linebreaks I added):
Before While 2705
After While 2705
Before While 2707
After While 2707
Before While 2722
After While 2722
Before While 2722
After While 2722
Before While 2738
After While 2738
Before While 2739
After While 2739
Before While 2772
After While 2772
Before While 2772
After While 2772
Before While 2788
After While 2788
Before While 2789
After While 2789
Before While 2805
After While 2805
Before While 2805
After While 2805
gestouch_internal function onTouchMove(touch:Touch):void
{
var gesturesForTouch:Vector.<Gesture> = _gesturesForTouchMap[touch] as Vector.<Gesture>;
var gesture:Gesture;
var i:uint = gesturesForTouch.length;
trace("Before While "+touch.time);
while (i-- > 0)
{
gesture = gesturesForTouch[i];
if (!_dirtyGesturesMap[gesture] && gesture.isTrackingTouch(touch.id))
{
gesture.touchMoveHandler(touch);
}
else
{
// gesture is no more interested in this touch (e.g. ignoreTouch was called)
gesturesForTouch.splice(i, 1);
}
}
trace("After While "+touch.time);
trace("");
}
from gestouch.
Noooo =))) keep the traces in gesture or handler also) this way we can see if theres sequence like "before, handler, handler, after" — there's bug in manager. If it's "before, handler, after" — manager is fine and dammit wtf.
from gestouch.
I see. Added traces back to the PanGesture.as onTouchMove(). That appears to only be called once =)
Before While 1141
PanGesture onTouchMove: 332, 299 location: (x=332, y=299) touch.time: 1141 touch location: (x=332, y=299)
_offsetX: 0 offsetY: 0
After While 1141
Before While 1157
PanGesture onTouchMove: 332, 299 location: (x=328, y=301) touch.time: 1157 touch location: (x=328, y=301)
_offsetX: -4 offsetY: 2
After While 1157
Before While 1157
PanGesture onTouchMove: 328, 301 location: (x=328, y=301) touch.time: 1157 touch location: (x=328, y=301)
_offsetX: 0 offsetY: 0
After While 1157
Before While 1175
PanGesture onTouchMove: 328, 301 location: (x=314, y=309) touch.time: 1175 touch location: (x=314, y=309)
_offsetX: -14 offsetY: 8
After While 1175
Before While 1175
PanGesture onTouchMove: 314, 309 location: (x=314, y=309) touch.time: 1175 touch location: (x=314, y=309)
_offsetX: 0 offsetY: 0
After While 1175
Before While 1189
PanGesture onTouchMove: 314, 309 location: (x=312, y=312) touch.time: 1189 touch location: (x=312, y=312)
_offsetX: -2 offsetY: 3
After While 1189
Before While 1189
PanGesture onTouchMove: 312, 312 location: (x=312, y=312) touch.time: 1189 touch location: (x=312, y=312)
_offsetX: 0 offsetY: 0
After While 1189
Before While 1206
PanGesture onTouchMove: 312, 312 location: (x=312, y=315) touch.time: 1206 touch location: (x=312, y=315)
_offsetX: 0 offsetY: 3
After While 1206
Before While 1206
PanGesture onTouchMove: 312, 315 location: (x=312, y=315) touch.time: 1206 touch location: (x=312, y=315)
_offsetX: 0 offsetY: 0
After While 1206
Relevant portion of PanGesture.as onTouchMove:
else if (state == GestureState.BEGAN || state == GestureState.CHANGED)
{
prevLocationX = _location.x;
prevLocationY = _location.y;
updateLocation();
trace("PanGesture onTouchMove: "+prevLocationX+", "+prevLocationY+ " location: " + _location +" touch.time: "+ touch.time + " touch location: " +touch.location);
_offsetX = _location.x - prevLocationX;
_offsetY = _location.y - prevLocationY;
trace("_offsetX: " +_offsetX+" offsetY: "+_offsetY);
setState(GestureState.CHANGED);
}
from gestouch.
Great. So I found out that native event TouchEvent.TOUCH_MOVE is dispatched even when it's locations is the same, but touch size has changed. So try this commit 4398712
from gestouch.
Nice. We'll try this version asap and see how things go. Having the extra cycles really didn't cause problems, but fixing it will hopefully benefit performance.
from gestouch.
Well actually I consider it as a bug since no actual move was happening. And other than conceptual confusion it also could lead to wrong velocity calculation.
from gestouch.
Related Issues (20)
- Limit panning in TransformGesture HOT 2
- DoubleTab and zoom HOT 3
- use Gestouch in Normal As3 HOT 1
- Gestouch suddenly stopped working on Windows 10 with latest Animate CC HOT 2
- How can I use gestouch in starling2 and normal swf file with together ? HOT 1
- freerotation behaviour HOT 4
- SwipeGesture and Drag Drop HOT 1
- swipe container and tap with button scaling up HOT 19
- air error HOT 6
- Errors when using swipe gesture with Starling HOT 2
- Starling.dispose() loses Gestouch swipe HOT 3
- Gestouch with Air18 HOT 8
- Gestouch suddenly stops working HOT 7
- Cannot register CLICK events on items inside an item dragged with Gestouch HOT 2
- example for drag and zoom and rotate. all together with gestouch HOT 10
- Listeners not working in certain circumstances HOT 15
- SingleTap and DoubleTap - suggestions? HOT 3
- TUIO and Starling HOT 2
- Shaky TransformGesture HOT 5
- Dispatch SwipeGesture to repeat Event HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gestouch.