Skip to content

Commit b1a7c19

Browse files
author
Adam Bradley
committed
fix(toggle): Changed tap listener to use "release", closes #882 #881
1 parent f1ed4b0 commit b1a7c19

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

js/ext/angular/src/directive/ionicTouch.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ angular.module('ionic.ui.touch', [])
3131
});
3232
});
3333

34-
element[0].addEventListener('touchend', onTap, false);
34+
ionic.on("release", onTap, element[0]);
3535

3636
// Hack for iOS Safari's benefit. It goes searching for onclick handlers and is liable to click
3737
// something else nearby.
3838
element.onclick = function(event) { };
3939

4040
scope.$on('$destroy', function () {
41-
element[0].removeEventListener('touchend', onTap);
41+
ionic.off("release", onTap, element[0]);
4242
});
4343
};
4444
}])

js/ext/angular/test/list.html

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
66
<link rel="stylesheet" href="../../../../dist/css/ionic.css">
77
<script src="../../../../dist/js/ionic.bundle.js"></script>
8+
<style>
9+
#click-notify {
10+
position: absolute;
11+
display: none;
12+
top: 150px;
13+
left: 48%;
14+
z-index: 9999;
15+
background: red;
16+
}
17+
</style>
818
</head>
919
<body ng-controller="TestCtrl">
1020
<div id="click-notify">CLICK!</div>

js/utils/tap.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,6 @@
184184
}, REMOVE_PREVENT_DELAY);
185185
}
186186

187-
function touchEnd(e) {
188-
tapPolyfill(e);
189-
removeClickPrevent(e);
190-
}
191-
192187
function stopEvent(e){
193188
e.stopPropagation();
194189
e.preventDefault();
@@ -223,13 +218,14 @@
223218
REMOVE_PREVENT_DELAY = 800;
224219
}
225220

226-
// global action event listener for HTML elements that were tapped or held by the user
227-
document.addEventListener('touchend', touchEnd, false);
228-
229221
// set global click handler and check if the event should stop or not
230222
document.addEventListener('click', preventGhostClick, true);
231223

232-
// listener used to remove ghostclick prevention
224+
// global release event listener polyfill for HTML elements that were tapped or held
225+
ionic.on("release", tapPolyfill, document);
226+
227+
// listeners used to remove ghostclick prevention
228+
document.addEventListener('touchend', removeClickPrevent, false);
233229
document.addEventListener('mouseup', removeClickPrevent, false);
234230

235231
// in the case the user touched the screen, then scrolled, it shouldn't fire the click

0 commit comments

Comments
 (0)