Skip to content

Commit

Permalink
make PASSIVE_TOUCH take an argument
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Nov 30, 2017
1 parent 84fa3bf commit c5407a8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/utils/gestures.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@
/**
* 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 {
Expand Down Expand Up @@ -481,8 +485,7 @@
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;
Expand Down Expand Up @@ -515,8 +518,7 @@
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));
}
}
}
Expand Down

0 comments on commit c5407a8

Please sign in to comment.