mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
tap polyfill removeClickPrevent and label fixes
This commit is contained in:
@@ -68,8 +68,13 @@
|
||||
|
||||
<label class="label1">
|
||||
<input type="radio" name="radio" id="radio1" class="radio1">
|
||||
</label>
|
||||
<input type="radio" name="radio" id="radio2" class="radio2">
|
||||
</label>
|
||||
<input type="radio" name="radio" id="radio2" class="radio2">
|
||||
|
||||
<label class="label2">
|
||||
<input type="checkbox" name="checkbox1" id="checkbox1" class="checkbox1">
|
||||
</label>
|
||||
<input type="checkbox" name="checkbox2" id="checkbox2" class="checkbox2">
|
||||
|
||||
</div>
|
||||
|
||||
@@ -241,7 +246,7 @@
|
||||
// console.debug('mousemove', 'clientX: ' + event.clientX, 'clientY: ' + event.clientY);
|
||||
// });
|
||||
document.addEventListener('click', function(event){
|
||||
console.debug('click', 'clientX: ' + event.clientX, 'clientY: ' + event.clientY);
|
||||
console.debug('click', 'clientX: ' + event.clientX, 'clientY: ' + event.clientY, event.target.tagName);
|
||||
});
|
||||
document.getElementById('clear').addEventListener('click', function(){
|
||||
setTimeout(clearMsgs, 200);
|
||||
|
||||
@@ -18,8 +18,11 @@
|
||||
})();
|
||||
|
||||
// polyfill use to simulate native "tap"
|
||||
ionic.tapElement = function(ele, e) {
|
||||
ionic.tapElement = function(target, e) {
|
||||
// simulate a normal click by running the element's click method then focus on it
|
||||
|
||||
var ele = target.control || target;
|
||||
|
||||
if(ele.disabled) return;
|
||||
|
||||
console.debug('tapElement', ele.tagName, ele.className);
|
||||
@@ -46,6 +49,11 @@
|
||||
if( !isRecentTap(e) ) {
|
||||
recordCoordinates(e);
|
||||
}
|
||||
|
||||
if(target.control) {
|
||||
console.debug('tapElement, target.control, stop');
|
||||
return stopEvent(e);
|
||||
}
|
||||
};
|
||||
|
||||
function tapPolyfill(orgEvent) {
|
||||
@@ -66,16 +74,11 @@
|
||||
if( ele.tagName === "INPUT" ||
|
||||
ele.tagName === "A" ||
|
||||
ele.tagName === "BUTTON" ||
|
||||
ele.tagName === "LABEL" ||
|
||||
ele.tagName === "TEXTAREA" ||
|
||||
ele.tagName === "SELECT" ) {
|
||||
|
||||
return ionic.tapElement(ele, e);
|
||||
|
||||
} else if( ele.tagName === "LABEL" ) {
|
||||
// check if the tapped label has an input associated to it
|
||||
if(ele.control) {
|
||||
return ionic.tapElement(ele.control, e);
|
||||
}
|
||||
}
|
||||
ele = ele.parentElement;
|
||||
}
|
||||
@@ -158,13 +161,9 @@
|
||||
|
||||
function removeClickPrevent(e) {
|
||||
setTimeout(function(){
|
||||
if(e.target && e.target.control && e.target.control.labelLastTap) {
|
||||
e.target.control.labelLastTap = null;
|
||||
}
|
||||
var c = isRecentTap(e);
|
||||
if(c) delete tapCoordinates[c.id];
|
||||
var tap = isRecentTap(e);
|
||||
if(tap) delete tapCoordinates[tap.id];
|
||||
}, REMOVE_PREVENT_DELAY);
|
||||
return stopEvent(e);
|
||||
}
|
||||
|
||||
function stopEvent(e){
|
||||
|
||||
Reference in New Issue
Block a user