Skip to content

Commit

Permalink
fix(tap): Prevent multiple clicks when overriding cordova object, closes
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Apr 2, 2014
1 parent 5b0f5d0 commit 5f3a1d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
3 changes: 3 additions & 0 deletions js/ext/angular/test/clickTests.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
background: #FFFFCC;
}
</style>
<script>
var cordova = {};
</script>
</head>

<body ng-controller="MyCtrl">
Expand Down
22 changes: 11 additions & 11 deletions js/utils/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
// 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);
// 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);
// 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);

// in the case the user touched the screen, then scrolled, it shouldn't fire the click
document.addEventListener('touchstart', recordStartCoordinates, false);
});

})(this, document, ionic);

0 comments on commit 5f3a1d2

Please sign in to comment.