0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-06 03:53:23 +01:00

Disabling all click events after a touchStart

This commit is contained in:
peteruithoven 2014-01-16 12:04:25 +01:00
parent c697806385
commit a952a1ee7b

View File

@ -1,5 +1,6 @@
(function($) { (function($) {
var clickEnabled = true;
$.fn.Button = function() { $.fn.Button = function() {
return $(this).each(function(){ return $(this).each(function(){
@ -32,6 +33,7 @@
//android+chrome-specific hack //android+chrome-specific hack
if (e.originalEvent.changedTouches != undefined) { if (e.originalEvent.changedTouches != undefined) {
var offset = $(element).offset();
_x = e.originalEvent.changedTouches[0].pageX - offset.left; _x = e.originalEvent.changedTouches[0].pageX - offset.left;
_y = e.originalEvent.changedTouches[0].pageY - offset.top; _y = e.originalEvent.changedTouches[0].pageY - offset.top;
} }
@ -61,6 +63,7 @@
} }
var onTouchStart = function(e) { var onTouchStart = function(e) {
clickEnabled = false;
updateCursor(e); updateCursor(e);
startDownTimer(); startDownTimer();
$(element).trigger("onButtonClick",{x:_x,y:_y}); $(element).trigger("onButtonClick",{x:_x,y:_y});
@ -101,6 +104,7 @@
} }
var onClick = function(e) { var onClick = function(e) {
if(!clickEnabled) return;
updateCursor(e); updateCursor(e);
stopDownTimer(); stopDownTimer();
$(element).trigger("onButtonClick",{x:_x,y:_y}); $(element).trigger("onButtonClick",{x:_x,y:_y});