Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Touch device ghost click triggers on different element Reply To: Touch device ghost click triggers on different element

#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.