mirror of
https://github.com/Polymer/polymer.git
synced 2026-08-19 01:14:44 -05:00
Allow configuring cancelling synthetic click behavior (#5536)
This commit is contained in:
committed by
Tim van der Lippe
parent
a7cb0ae086
commit
9a8bca4954
@@ -226,6 +226,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
}
|
||||
|
||||
function ignoreMouse(e) {
|
||||
if (!Polymer.cancelSyntheticClickEvents) {
|
||||
return;
|
||||
}
|
||||
if (!POINTERSTATE.mouse.mouseIgnoreJob) {
|
||||
setupTeardownMouseCanceller(true);
|
||||
}
|
||||
@@ -335,9 +338,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
stateObj.upfn = null;
|
||||
}
|
||||
|
||||
// use a document-wide touchend listener to start the ghost-click prevention mechanism
|
||||
// Use passive event listeners, if supported, to not affect scrolling performance
|
||||
document.addEventListener('touchend', ignoreMouse, SUPPORTS_PASSIVE ? {passive: true} : false);
|
||||
if (Polymer.cancelSyntheticClickEvents) {
|
||||
// use a document-wide touchend listener to start the ghost-click prevention mechanism
|
||||
// Use passive event listeners, if supported, to not affect scrolling performance
|
||||
document.addEventListener('touchend', ignoreMouse, SUPPORTS_PASSIVE ? {passive: true} : false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Module for adding listeners to a node for the following normalized
|
||||
|
||||
@@ -122,5 +122,21 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
Polymer.setLegacyOptimizations = function(useLegacyOptimizations) {
|
||||
Polymer.legacyOptimizations = useLegacyOptimizations;
|
||||
};
|
||||
|
||||
Polymer.cancelSyntheticClickEvents = typeof Polymer.cancelSyntheticClickEvents === 'boolean'
|
||||
? Polymer.cancelSyntheticClickEvents : true;
|
||||
|
||||
/**
|
||||
* Sets `setCancelSyntheticEvents` globally for all elements to cancel synthetic click events
|
||||
* fired by older mobile browsers. Modern browsers no longer fire synthetic click events, and
|
||||
* the cancellation behavior can interfere when programmatically clicking on elements.
|
||||
*
|
||||
* @param {boolean} useCancelSyntheticClickEvents enable or disable cancelling synthetic
|
||||
* events
|
||||
* @return {void}
|
||||
*/
|
||||
Polymer.setCancelSyntheticClickEvents = function(useCancelSyntheticClickEvents) {
|
||||
Polymer.cancelSyntheticClickEvents = useCancelSyntheticClickEvents;
|
||||
};
|
||||
})();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user