From 83663a428eaf72a12c79dae39d3869954e3da954 Mon Sep 17 00:00:00 2001 From: Rand Scullard Date: Fri, 19 Dec 2014 16:34:21 -0500 Subject: [PATCH] fix41: Call event.preventDefault before simulating a click event, to avoid getting two clicks. --- jquery.ui.touch-punch.js | 3 ++- jquery.ui.touch-punch.min.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/jquery.ui.touch-punch.js b/jquery.ui.touch-punch.js index 0ac3ba1..ea1d826 100755 --- a/jquery.ui.touch-punch.js +++ b/jquery.ui.touch-punch.js @@ -1,4 +1,4 @@ -/*! +/*! * jQuery UI Touch Punch 0.2.3 * * Copyright 2011–2014, Dave Furfero @@ -134,6 +134,7 @@ if (!this._touchMoved) { // Simulate the click event + event.preventDefault(); simulateMouseEvent(event, 'click'); } diff --git a/jquery.ui.touch-punch.min.js b/jquery.ui.touch-punch.min.js index cc787e0..a6107da 100644 --- a/jquery.ui.touch-punch.min.js +++ b/jquery.ui.touch-punch.min.js @@ -8,4 +8,4 @@ * jquery.ui.widget.js * jquery.ui.mouse.js */ -(function(d){d.support.touch="ontouchend" in document;if(!d.support.touch){return;}var c=d.ui.mouse.prototype,f=c._mouseInit,g=c._mouseDestroy,e=c._mouseDown,h=c._mouseMove,b,i;function a(k,l){if(k.originalEvent.touches.length>1){return;}b=k;var m=k.originalEvent.changedTouches[0],j=document.createEvent("MouseEvents");j.initMouseEvent(l,true,true,window,1,m.screenX,m.screenY,m.clientX,m.clientY,false,false,false,false,0,null);k.target.dispatchEvent(j);}c._touchStart=function(k){var j=this;if(i||!j._mouseCapture(k.originalEvent.changedTouches[0])){return;}i=true;j._touchMoved=false;a(k,"mouseover");a(k,"mousemove");a(k,"mousedown");};c._touchMove=function(j){if(!i){return;}this._touchMoved=true;a(j,"mousemove");};c._touchEnd=function(j){if(!i){return;}a(j,"mouseup");a(j,"mouseout");if(!this._touchMoved){a(j,"click");}i=false;};c._mouseInit=function(){var j=this;j.element.bind({touchstart:d.proxy(j,"_touchStart"),touchmove:d.proxy(j,"_touchMove"),touchend:d.proxy(j,"_touchEnd")});f.call(j);};c._mouseDestroy=function(){var j=this;j.element.unbind({touchstart:d.proxy(j,"_touchStart"),touchmove:d.proxy(j,"_touchMove"),touchend:d.proxy(j,"_touchEnd")});g.call(j);};c._mouseDown=function(k){var j=this;e.call(j,k);if(k.isDefaultPrevented()){b.preventDefault();}};c._mouseMove=function(k){var j=this;h.call(j,k);if(k.isDefaultPrevented()){b.preventDefault();}};})(jQuery); \ No newline at end of file +(function(d){d.support.touch="ontouchend" in document;if(!d.support.touch){return;}var c=d.ui.mouse.prototype,f=c._mouseInit,g=c._mouseDestroy,e=c._mouseDown,h=c._mouseMove,b,i;function a(k,l){if(k.originalEvent.touches.length>1){return;}b=k;var m=k.originalEvent.changedTouches[0],j=document.createEvent("MouseEvents");j.initMouseEvent(l,true,true,window,1,m.screenX,m.screenY,m.clientX,m.clientY,false,false,false,false,0,null);k.target.dispatchEvent(j);}c._touchStart=function(k){var j=this;if(i||!j._mouseCapture(k.originalEvent.changedTouches[0])){return;}i=true;j._touchMoved=false;a(k,"mouseover");a(k,"mousemove");a(k,"mousedown");};c._touchMove=function(j){if(!i){return;}this._touchMoved=true;a(j,"mousemove");};c._touchEnd=function(j){if(!i){return;}a(j,"mouseup");a(j,"mouseout");if(!this._touchMoved){j.preventDefault();a(j,"click");}i=false;};c._mouseInit=function(){var j=this;j.element.bind({touchstart:d.proxy(j,"_touchStart"),touchmove:d.proxy(j,"_touchMove"),touchend:d.proxy(j,"_touchEnd")});f.call(j);};c._mouseDestroy=function(){var j=this;j.element.unbind({touchstart:d.proxy(j,"_touchStart"),touchmove:d.proxy(j,"_touchMove"),touchend:d.proxy(j,"_touchEnd")});g.call(j);};c._mouseDown=function(k){var j=this;e.call(j,k);if(k.isDefaultPrevented()){b.preventDefault();}};c._mouseMove=function(k){var j=this;h.call(j,k);if(k.isDefaultPrevented()){b.preventDefault();}};})(jQuery); \ No newline at end of file