Last Updated: February 25, 2016
·
1.549K
· emi420

How to fix Android double click/touch

I use Zepto for one mobile project and this was my solution for fix this behavior on Android devices.

Detect touch support:

if ( !!('ontouchstart' in window) ) {

Wrapper for the Zepto function:

$.fn._on = $.fn.on;
$.fn.on = function(event, selector, data, callback, one) {

Remove 'click' event that causes the problem:

if (event.indexOf("click") > -1) {
    event = event.replace("click","");
}

And return scope:

return $.fn._on.call(this, event, selector, data, callback, one);

Full code:

if ( !!('ontouchstart' in window) ) {
    $.fn._on = $.fn.on;
    $.fn.on = function(event, selector, data, callback, one) {
        if (event.indexOf("click") > -1) {
            event = event.replace("click","");
        }
        return $.fn._on.call(this, event, selector, data, callback, one);
    };
}

https://github.com/emi420/Mootor/blob/master/source/js/clickfix.js