Open Developsaurus opened 11 years ago
Hey. I'm not 100% sure that the 300ms delay can be eliminated while supporting the taphold. Do you see a way that it can?
I think when the user first touches a.cat (in your example), the purpose of fastClick is to respond immediately without a delay. The purpose of the delay is to let figure out did the user mean to tap, or did they mean to do some other gesture (tapHold, swipe, etc).
The code suppresses future events from that touch, if that was disabled then the tapHold might fire too after the fastClick, is that what you're looking for?
I'm still rather new to doing complex Javascript development, so using this to eliminate onClick delay for a PhoneGap/jQuery Mobile app has been great. But I've run into an issue:
At the moment, this code doesn't seem to accommodate a taphold event. In my code, I bind to taphold for an item. But this never fires if I set a fastClick event for it as well. Ideally, I'd like to be able to have both co-existing, so a user can tap to go to a new page, or taphold to bring up a dialog.
Is this possible? If nothing else, could it not filter out touchstart events that have a touchend event after a set threshold? Just a thought. Thanks!
Example Code:
$('a.cat').bind('taphold', function (e) { $( "#homeDialog" ).popup( "open" ); });
$('a.cat').fastClick(function(e) { $.mobile.changePage("categoryPage.html", {transition: "slide"}); });
fastClick fires, but taphold does not, no longer how long the tap is held for.