PDA

View Full Version : Issue (Bug?) with mixed "singleTab" and "doubleTab" events



wrybit
26 Nov 2010, 12:25 PM
Hy,

I'm not very experienced with Sencha Touch jet,
when I use a xType 'list' and add a listeners like:


...
listeners: {
scope : this,
itemTap : this.onTapListAction,
itemDoubleTap : this.onTapListAction,
itemSwipe : this.onTapListAction
}
...


to the items config of a Ext.Panel I found get an
Issue with a Mixed "singleTab" & "doubleTab" events.



...
onTapListAction: function(listComponent, index, item, eventObject){
switch (eventObject.type) {
case 'swipe':
// swipe action ...
break;
case 'doubletap':
// doubletap action ...
break;
case 'singletap':
// singletap action ...
break;
}
},
...


When the "doubletap" event gets called, than
the "singletap" gets always call before hand. :(

How could I avoid that behavior?

Greez Jens

Steffen Hiller
26 Nov 2010, 2:30 PM
I just checked the source. There's no config option that could solve your problem.
They have a singleTapThreshold (400 ms) which prevents the second tap from firing a singletap event again, which doesn't solve your problem though.

What you could do is that you use setTimeout or http://dev.sencha.com/deploy/touch/docs/?class=Ext.util.DelayedTask and delay the task until you are sure that the user isn't doing a doubletap.
If no doubletap is happening, execute your singletap handler.

The default doubleTapThreshold is 800 ms. Check the source of Ext.gesture.Tap for more info on that.

Either way, if the user wants to do a singletap only, he might feel a delay. Though maybe putting a singletap and doubletap event on the same element isn't a perfect solution.

Hope that helps.

wrybit
28 Nov 2010, 3:18 AM
Hy,

thx for your quick answer. I saw the same before. ;(
But I hoped there is a way to modify it. So there
must be a option for the TabThreshold in the next
release. BTW: 800 ms for a DoubleTab is very long.

But there must be a native way to fix that issue.
The current solution isn't the way to go ...

http://dev.sencha.com/deploy/touch/examples/kitchensink/
go to Touch Events and make a DoubleTab there is no way
to avoid a SingleTab. It can't stay like that :)

I fear the .delay() solution is to laggy to be a real one.
Thx for you help. But I think we didn't found a solution.

Greez Jens

wrybit
28 Nov 2010, 4:50 AM
Used your suggestion:



onTapListAction: function(listComponent, index, item, eventObject){
switch (eventObject.type) {
case 'swipe':

// .. swipe action ..

break;
case 'singletap':
if (this.delayedTask === undefined) {
this.delayedTask = new Ext.util.DelayedTask(function () {
this.delayedTask = undefined;

// .. singletap action ..

}, this);
}
this.delayedTask.delay(250);
break;
case 'doubletap':
if (this.delayedTask !== undefined) {
this.delayedTask.cancel();
this.delayedTask = undefined;
}

// .. doubletap action ..

break;
}
},


Found here: http://www.sencha.com/forum/showthread.php?115353-Tap-and-Double-Tap

Works fine, thx! But for sure the 250ms delay feels a bit slower.
Hopefully the future will bring a better Touch handler for Sencha.

Greez Jens

Steffen Hiller
28 Nov 2010, 7:00 AM
I'm afraid that there won't be a better solution. It's just the same as the click vs. dblclick event in Ext JS.
How is the app supposed to know that the user is going to double tap?

Do you know of any other app or native app that allows single tap and double tap on one element but doesn't have a delay when you single tap? Or a non mobile app where you can click and double click on one element?

wrybit
4 Dec 2010, 6:28 AM
Hy,

this isn't a good solution, as I had to find out. :(
Sadly if you attach an Event-Listener to a List and
the Items in the List, you could trigger the Double-
Tab when you hit fast enough two Items in a row.

Maybe it's my implementation, but all in all the
Touch Listener feels quite uncompleted to me.

Greez Jens