Skip to content

Commit

Permalink
Revert "Ghostclick killer"
Browse files Browse the repository at this point in the history
This reverts commit e36af9a.
  • Loading branch information
Max Degterev committed Feb 9, 2012
1 parent e36af9a commit f5cc377
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions zepto.onpress.js
Expand Up @@ -12,34 +12,42 @@
target;

if ($.os.touch) {
var handleGhostClick = function(e) {
e.preventDefault();
e.stopPropagation();
};
doc.on('touchstart', function(e) {
var handleTouchStart = function(e) {
touches.x = e.touches[0].pageX;
touches.y = e.touches[0].pageY;
hasMoved = false;
target = e.target;
});
doc.on('touchmove', function(e) {

};
var handleTouchMove = function(e) {
if(Math.abs(e.touches[0].pageX - touches.x) > 10 || Math.abs(e.touches[0].pageY - touches.y) > 10) {
hasMoved = true;
}
});
doc.on('touchend', function(e) {

};
var handleTouchEnd = function(e) {
if ((target === e.target) && !hasMoved) {
$(e.target).trigger('press', e);
doc.one('click', handleGhostClick); // kills ghostclick on Opera somehow
$(e.target).trigger('press', e);
doc.one('click', handleGhostClick); // kills ghostclick on Opera somehow
}
});
};
var handleGhostClick = function(e) {
e.preventDefault();
e.stopPropagation();
};

doc.on('touchstart', handleTouchStart);
doc.on('touchmove', handleTouchMove);
doc.on('touchend', handleTouchEnd);
}
else {
doc.on('click', function(e) {
$(e.target).trigger('press', e);
});
var handleClick = function(e) {
$(e.target).trigger('press', e);
};
doc.on('click', handleClick);
}

$.fn.onpress = function(callb) {
this.on('press', callb);
};
})(Zepto);
})(Zepto);

0 comments on commit f5cc377

Please sign in to comment.