06.02.2018, 14:13
Hello,
what is appropriate way to add longclick event on object which by default has only click event. I don't to delete this click event, I want only additionally add longclick. Now I've tried something like below:
But it is triggered with also default click, but I want to cancel click event when longpress is detected. Maybe admin have some advice
what is appropriate way to add longclick event on object which by default has only click event. I don't to delete this click event, I want only additionally add longclick. Now I've tried something like below:
Code:
function onLongClick(selector, timeout, callback) {
let touchstart, touchend;
selector.on('touchstart mousedown', function(e) {
touchstart = e.timeStamp;
})
selector.on('touchend mouseup', function(e) {
touchend = e.timeStamp;
if (touchend - touchstart > timeout) callback();
})
}
But it is triggered with also default click, but I want to cancel click event when longpress is detected. Maybe admin have some advice