I've been able to successfully play with the touchstart, touchmove, and touchend events on Android using jQuery and an HTML page. Now I'm trying to see what the trick is to determine a long tap event, where one taps and holds for 3 seconds. I can't seem to figure this out yet. I'm wanting to this purely in jQuery without Sencha Touch, JQTouch, jQMobile, etc.
I like the concept of jQTouch, although it doesn't provide me a whole lot and some of my code breaks with it. With Sencha Touch, I'm not a fan of moving away from jQuery into Ext.js and some new way of doing Javascript abstraction, especially when jQuery is so capable. So, I want to figure this out with jQuery alone. I've been able to do many jQTouch and Sencha Touch things on my own using jQuery. And jQMobile is still too beta and not directed enough to the Android yet.
Timers not used but will only fire after user releases his finger after a long tap.
var startTime, endTime;
var gbMove = false;
window.addEventListener('touchstart',function(event) {
startTime = new Date().getTime();
gbMove = false;
},false);
window.addEventListener('touchmove',function(event) {
gbMove = true;
},false);
window.addEventListener('touchend',function(event) {
endTime = new Date().getTime();
if(!gbMove && (endTime-startTime)/1000 > 2)
alert('tap hold event');
},false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With