mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
4
js/ext/angular/src/directive/ionicTouch.js
vendored
4
js/ext/angular/src/directive/ionicTouch.js
vendored
@@ -31,14 +31,14 @@ angular.module('ionic.ui.touch', [])
|
||||
});
|
||||
});
|
||||
|
||||
element[0].addEventListener('touchend', onTap, false);
|
||||
ionic.on("release", onTap, element[0]);
|
||||
|
||||
// Hack for iOS Safari's benefit. It goes searching for onclick handlers and is liable to click
|
||||
// something else nearby.
|
||||
element.onclick = function(event) { };
|
||||
|
||||
scope.$on('$destroy', function () {
|
||||
element[0].removeEventListener('touchend', onTap);
|
||||
ionic.off("release", onTap, element[0]);
|
||||
});
|
||||
};
|
||||
}])
|
||||
|
||||
@@ -5,6 +5,16 @@
|
||||
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
|
||||
<link rel="stylesheet" href="../../../../dist/css/ionic.css">
|
||||
<script src="../../../../dist/js/ionic.bundle.js"></script>
|
||||
<style>
|
||||
#click-notify {
|
||||
position: absolute;
|
||||
display: none;
|
||||
top: 150px;
|
||||
left: 48%;
|
||||
z-index: 9999;
|
||||
background: red;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body ng-controller="TestCtrl">
|
||||
<div id="click-notify">CLICK!</div>
|
||||
|
||||
@@ -184,11 +184,6 @@
|
||||
}, REMOVE_PREVENT_DELAY);
|
||||
}
|
||||
|
||||
function touchEnd(e) {
|
||||
tapPolyfill(e);
|
||||
removeClickPrevent(e);
|
||||
}
|
||||
|
||||
function stopEvent(e){
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
@@ -223,13 +218,14 @@
|
||||
REMOVE_PREVENT_DELAY = 800;
|
||||
}
|
||||
|
||||
// global action event listener for HTML elements that were tapped or held by the user
|
||||
document.addEventListener('touchend', touchEnd, false);
|
||||
|
||||
// set global click handler and check if the event should stop or not
|
||||
document.addEventListener('click', preventGhostClick, true);
|
||||
|
||||
// listener used to remove ghostclick prevention
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user