blur active input w/ setTimeout

This commit is contained in:
Adam Bradley
2014-02-16 22:07:19 -06:00
parent 35ad05163a
commit f736ae510e

View File

@@ -47,8 +47,9 @@
if(ele.tagName === 'INPUT' || ele.tagName === 'TEXTAREA' || ele.tagName === 'SELECT') {
ele.focus();
e.preventDefault();
} else {
ele.blur();
blurActive();
}
// remember the coordinates of this tap so if it happens again we can ignore it
@@ -103,12 +104,7 @@
// they didn't tap one of the above elements
// if the currently active element is an input, and they tapped outside
// of the current input, then unset its focus (blur) so the keyboard goes away
ele = document.activeElement;
if(ele && (ele.tagName === "INPUT" ||
ele.tagName === "TEXTAREA" ||
ele.tagName === "SELECT")) {
ele.blur();
}
blurActive();
}
function preventGhostClick(e) {
@@ -159,6 +155,18 @@
return false;
}
function blurActive() {
var ele = document.activeElement;
if(ele && (ele.tagName === "INPUT" ||
ele.tagName === "TEXTAREA" ||
ele.tagName === "SELECT")) {
// using a timeout to prevent funky scrolling while a keyboard hides
setTimeout(function(){
ele.blur();
}, 400);
}
}
function isRecentTap(event) {
// loop through the tap coordinates and see if the same area has been tapped recently
var tapId, existingCoordinates, currentCoordinates,