Skip to content

Commit

Permalink
Revert "Ghostclick killer"
Browse files Browse the repository at this point in the history
This reverts commit 59c5636.
  • Loading branch information
Max Degterev committed Feb 9, 2012
1 parent f5cc377 commit 943fc53
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions zepto.onpress.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,25 @@
target;

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

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

};
var handleTouchEnd = function(e) {
if ((target === e.target) && !hasMoved) {
$(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);
});
doc.on('touchend', function(e) {
((target === e.target) && !hasMoved) && $(e.target).trigger('press', e);
});
}
else {
var handleClick = function(e) {
$(e.target).trigger('press', e);
};
doc.on('click', handleClick);
doc.on('click', function(e) {
$(e.target).trigger('press', e);
});
}

$.fn.onpress = function(callb) {
Expand Down

0 comments on commit 943fc53

Please sign in to comment.