From 5f3a1d21c6352e51f450dbdacace1e527048698f Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Wed, 2 Apr 2014 09:57:16 -0500 Subject: [PATCH] fix(tap): Prevent multiple clicks when overriding cordova object, closes #1022 --- js/ext/angular/test/clickTests.html | 3 +++ js/utils/tap.js | 28 ++++++++++++++-------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/js/ext/angular/test/clickTests.html b/js/ext/angular/test/clickTests.html index 4ea8e0d3d5..aabdd3c939 100644 --- a/js/ext/angular/test/clickTests.html +++ b/js/ext/angular/test/clickTests.html @@ -35,6 +35,9 @@ background: #FFFFCC; } + diff --git a/js/utils/tap.js b/js/utils/tap.js index aa8f4a4705..109f8419d8 100644 --- a/js/utils/tap.js +++ b/js/utils/tap.js @@ -213,24 +213,24 @@ var TOUCH_TOLERANCE_Y = 2; // how much the Y coordinates can be off between start/end, but still a click ionic.Platform.ready(function(){ - if(ionic.Platform.grade === 'c') { // low performing phones should have a longer ghostclick prevent REMOVE_PREVENT_DELAY = 800; } - - // set global click handler and check if the event should stop or not - document.addEventListener('click', preventGhostClick, true); - - // global release event listener polyfill for HTML elements that were tapped or held - ionic.on("release", tapPolyfill, document); - - // listeners used to remove ghostclick prevention - document.addEventListener('touchend', removeClickPrevent, false); - document.addEventListener('mouseup', removeClickPrevent, false); - - // in the case the user touched the screen, then scrolled, it shouldn't fire the click - document.addEventListener('touchstart', recordStartCoordinates, false); }); + // set global click handler and check if the event should stop or not + document.addEventListener('click', preventGhostClick, true); + + // global release event listener polyfill for HTML elements that were tapped or held + ionic.on("release", tapPolyfill, document); + + // listeners used to remove ghostclick prevention + document.addEventListener('touchend', removeClickPrevent, false); + document.addEventListener('mouseup', removeClickPrevent, false); + + // in the case the user touched the screen, then scrolled, it shouldn't fire the click + document.addEventListener('touchstart', recordStartCoordinates, false); + + })(this, document, ionic);