make PASSIVE_TOUCH take an argument

This commit is contained in:
Daniel Freedman
2017-11-30 14:10:05 -08:00
parent 84fa3bf383
commit c5407a8bea
+7 -5
View File
@@ -62,9 +62,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
/**
* Generate settings for event listeners, dependant on `Polymer.passiveTouchGestures`
*
* @param {string} eventName Event name to determine if `{passive}` option is needed
* @return {{passive: boolean} | undefined} Options to use for addEventListener and removeEventListener
*/
function PASSIVE_TOUCH() {
function PASSIVE_TOUCH(eventName) {
if (isMouseEvent(eventName) || eventName === 'touchend') {
return;
}
if (HAS_NATIVE_TA && SUPPORTS_PASSIVE && Polymer.passiveTouchGestures) {
return {passive: true};
} else {
@@ -481,8 +485,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
gobj[dep] = gd = {_count: 0};
}
if (gd._count === 0) {
let options = !isMouseEvent(dep) && dep !== 'touchend' && PASSIVE_TOUCH();
node.addEventListener(dep, this._handleNative, options);
node.addEventListener(dep, this._handleNative, PASSIVE_TOUCH(dep));
}
gd[name] = (gd[name] || 0) + 1;
gd._count = (gd._count || 0) + 1;
@@ -515,8 +518,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
gd[name] = (gd[name] || 1) - 1;
gd._count = (gd._count || 1) - 1;
if (gd._count === 0) {
let options = !isMouseEvent(dep) && dep !== 'touchend' && PASSIVE_TOUCH();
node.removeEventListener(dep, this._handleNative, options);
node.removeEventListener(dep, this._handleNative, PASSIVE_TOUCH(dep));
}
}
}