PDA

View Full Version : [CLOSED] Avoid itemtap after itemtaphold



sveins12
Jan 09, 2017, 10:05 PM
Is there a common way of avoiding itemtap being fired after itemtaphold?

sveins12
Jan 09, 2017, 11:16 PM
I found a "dirty" way to do it, but I think it should be built into extjs.



// regTapHold should be called from the itemtaphold handler.
function regTapHold(e) {
e._tapHold = true;
}

// checkTapHold should be called from the itemtap handler,
// and if this function returnes true, then skip further execution in that handler.
function checkTapHold(e) {
if (e._tapHold == true) {
e._tapHold = false;
return true;
} return false;
}

fabricio.murta
Jan 10, 2017, 7:20 PM
Hello @sveins12! And thanks for sharing the solution that works for you.

Seems there's not much discussion about this around, at least I couldn't find it. And I'm not completely sure in which scenarios that would be a problem, but sounds like an useful feature, for example, to show tooltips on a button when using mobile devices -- quick tap triggers it, and long tap just shows an explanation on what the button does.

I'm not sure about how "portable" across browsers is your approach, maybe that would be the main issue about handling the different tap behaviors.

sveins12
Jan 10, 2017, 8:51 PM
Usually I would like one behavior to occur when tapping quickly and another behavior when the user is holding down an item for a long time.

The problem is that itemtap is always fired when releasing the finger after a long-tap.

Maybe itemtap is not the correct event to use when tapping an item quickly/normally? Is there another event for this, which is not always fired when releasing the finger?

I have seen other discussions about this in the Sencha Touch forums, but I haven't found an acceptable solution there. By the way my solution is standard JavaScript, and I think it should work on all the browsers that support Extjs. But offcourse I don't know if it will mess up other touch events.

fabricio.murta
Jan 10, 2017, 10:11 PM
Hello @sveins12!

What component exactly are you using as base for the itemtap event? I believe your approach is nice, maybe there could be a 'fasttap' or 'quicktap', 'brieftap' -- something like this -- that implements this approach of checking if the tap was long or slow.

sveins12
Jan 11, 2017, 1:18 AM
I am using a Grid component.

fabricio.murta
Jan 11, 2017, 4:05 AM
Hello @sveins12!

Alright, now we are talking!.. You are about this then, right?
- Ext.Grid - itemtap event (http://docs.sencha.com/extjs/6.0.2/modern/Ext.grid.Grid.html#event-itemtap)

Do you see in the list, a little above itemsingletap event? Have you tried it instead of itemtap so that the taphold does not overlap?..

EDIT: But again, imagine itemtap didn't catch the event if the user held tap. We will (in potential) have cases of people who needed the tap to be handled (maybe not a redirecting feedback, but something to signal the application the tap has ended). If itemsingletap does not "filter" this specific behavior itself, the checktap() really sounds like a fair way to avoid the tap when the long event is overlapping.

sveins12
Jan 11, 2017, 5:46 PM
Yes, I tried itemsingletap now, and it has the same issue as itemtap. It also fires when releasing after itemtaphold is fired.

fabricio.murta
Jan 12, 2017, 5:53 PM
Hello @sveins12!

So, in the end, are you okay with using the approach you are, or you rather open a feature request for a specific event that will not be triggering when the tap is a long tap?

I don't see the current itemtap event behaving this way cause first, it will imply a breaking change for people that want the tap event to be triggered even after a longtap. As a feature, it could be confuse if people use both (say) 'briefitemtap' and 'itemtap' at the same component.

sveins12
Jan 12, 2017, 7:38 PM
For my part it's ok now that I have a workaround.

fabricio.murta
Jan 13, 2017, 12:15 AM
Hello @sveins12!

Okay, then maybe it will be alright mark this thread as closed then?