Home › Forums › JavaScript › Touch device ghost click triggers on different element › Reply To: Touch device ghost click triggers on different element
March 15, 2017 at 2:19 pm
#252826
Shikkediel
Participant
Never mind then, I’ll try posting the update again:
$(document).on('mousedown touchstart', subject, function(e) {
if (e.type == 'mousedown' && e.which != 1) return;
var mean = $(e.currentTarget);
mean.one('mouseup touchend', function(e) {
if (e.type == 'touchend' && !$('body').hasClass('punch')) $('body').addClass('punch');
else if ($('body').hasClass('punch')) return;
mean.trigger('page:tap');
});
})
.on('click', subject, function() {
$('body').removeClass('punch');
return false;
});
I think the ghost clicks might have been inexplicable extra touchend
events.
This will make sure only a single one is actively triggering.