fix(tap): Prevent multiple clicks when overriding cordova object, closes #1022

This commit is contained in:
Adam Bradley
2014-04-02 09:57:16 -05:00
parent 5b0f5d024c
commit 5f3a1d21c6
2 changed files with 17 additions and 14 deletions

View File

@@ -35,6 +35,9 @@
background: #FFFFCC;
}
</style>
<script>
var cordova = {};
</script>
</head>
<body ng-controller="MyCtrl">

View File

@@ -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);