From a952a1ee7b160cef91ff1e898ebb5ddde19e4a2f Mon Sep 17 00:00:00 2001 From: peteruithoven Date: Thu, 16 Jan 2014 12:04:25 +0100 Subject: [PATCH] Disabling all click events after a touchStart --- js/Button.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/Button.js b/js/Button.js index f3c46c4..78662d0 100644 --- a/js/Button.js +++ b/js/Button.js @@ -1,5 +1,6 @@ (function($) { + var clickEnabled = true; $.fn.Button = function() { return $(this).each(function(){ @@ -32,6 +33,7 @@ //android+chrome-specific hack if (e.originalEvent.changedTouches != undefined) { + var offset = $(element).offset(); _x = e.originalEvent.changedTouches[0].pageX - offset.left; _y = e.originalEvent.changedTouches[0].pageY - offset.top; } @@ -61,6 +63,7 @@ } var onTouchStart = function(e) { + clickEnabled = false; updateCursor(e); startDownTimer(); $(element).trigger("onButtonClick",{x:_x,y:_y}); @@ -101,6 +104,7 @@ } var onClick = function(e) { + if(!clickEnabled) return; updateCursor(e); stopDownTimer(); $(element).trigger("onButtonClick",{x:_x,y:_y});