Skip to content

Instantly share code, notes, and snippets.

@abrjagad
Created August 31, 2015 05:21
Show Gist options
  • Save abrjagad/25900261b284f3ce7dac to your computer and use it in GitHub Desktop.
Save abrjagad/25900261b284f3ce7dac to your computer and use it in GitHub Desktop.
$.event.special.abetap = {
delegateType: "tap",
bindType: "tap",
handle: function (event) {
var handleObj = event.handleObj;
var targetData = jQuery.data(event.target);
var ret = null;
event.preventDefault();
if (!targetData.counter && !targetData.timer) {
//debugger;
targetData.counter = Date.now();
targetData.timer = setTimeout(function () {
clearTimeout(targetData.timer);
delete targetData.counter;
}, 500);
console.log(targetData);
} else {
if (Date.now() - targetData.counter < 500) {
event.type = handleObj.origType;
ret = handleObj.handler.apply(this, arguments);
event.type = handleObj.type;
return ret;
}
clearTimeout(targetData.timer);
delete targetData.counter;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment