// Issue #160: on iOS 7, some input elements (e.g. date datetime month) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
// Issue #160: on iOS 7, some input elements (e.g. date datetime month) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
// Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through.
// Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37).
// Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through.
// Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37).
// Prevent any user-added listeners declared on FastClick element from being fired.
// Prevent any user-added listeners declared on FastClick element from being fired.
if(event.stopImmediatePropagation){
if(event.stopImmediatePropagation){
event.stopImmediatePropagation()
event.stopImmediatePropagation();
}else{
}else{
// Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
// Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
event.propagationStopped=true
event.propagationStopped=true;
}
}
// Cancel the event
// Cancel the event
event.stopPropagation()
event.stopPropagation();
event.preventDefault()
event.preventDefault();
returnfalse
returnfalse;
}
}
// If the mouse event is permitted, return true for the action to go through.
// If the mouse event is permitted, return true for the action to go through.
returntrue
returntrue;
}
};
/**
* On actual clicks, determine whether this is a touch-generated click, a click action occurring
/**
* naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or
* On actual clicks, determine whether this is a touch-generated click, a click action occurring
* an actual click which should be permitted.
* naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or
*
* an actual click which should be permitted.
* @param {Event} event
*
* @returns {boolean}
* @param {Event} event
*/
* @returns {boolean}
FastClick.prototype.onClick=function(event){
*/
varpermitted
FastClick.prototype.onClick=function(event){
varpermitted;
// It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early.
if(this.trackingClick){
// It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early.
this.targetElement=null
if(this.trackingClick){
this.trackingClick=false
this.targetElement=null;
returntrue
this.trackingClick=false;
}
returntrue;
}
// Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target.
// Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target.
// Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through.
if(!permitted){
// Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through.
this.targetElement=null
if(!permitted){
}
this.targetElement=null;
}
// If clicks are permitted, return true for the action to go through.
returnpermitted
// If clicks are permitted, return true for the action to go through.