From 84fa3bf38333f07bb1f189e981635463e0eb598f Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Wed, 29 Nov 2017 12:17:00 -0800 Subject: [PATCH] Do not set touchend listeners to passive `touchend` listeners do not need to be passive to enable more performant scrolling. With this change, most of the tradeoffs with enabling `passiveTouchGestures` disappear, leaving only the inability to control scrolling from `track`, `down`, and `move` gestures. Fixes #4961 --- lib/utils/gestures.html | 4 ++-- test/smoke/passive-gestures.html | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/utils/gestures.html b/lib/utils/gestures.html index b741455a9d..be74db8e90 100644 --- a/lib/utils/gestures.html +++ b/lib/utils/gestures.html @@ -481,7 +481,7 @@ gobj[dep] = gd = {_count: 0}; } if (gd._count === 0) { - let options = !isMouseEvent(dep) && PASSIVE_TOUCH(); + let options = !isMouseEvent(dep) && dep !== 'touchend' && PASSIVE_TOUCH(); node.addEventListener(dep, this._handleNative, options); } gd[name] = (gd[name] || 0) + 1; @@ -515,7 +515,7 @@ gd[name] = (gd[name] || 1) - 1; gd._count = (gd._count || 1) - 1; if (gd._count === 0) { - let options = !isMouseEvent(dep) && PASSIVE_TOUCH(); + let options = !isMouseEvent(dep) && dep !== 'touchend' && PASSIVE_TOUCH(); node.removeEventListener(dep, this._handleNative, options); } } diff --git a/test/smoke/passive-gestures.html b/test/smoke/passive-gestures.html index 90e7a9363c..cc578a2d52 100644 --- a/test/smoke/passive-gestures.html +++ b/test/smoke/passive-gestures.html @@ -40,11 +40,17 @@ is: 'x-passive', listeners: { 'down': 'prevent', - 'move': 'prevent' + 'move': 'prevent', + 'up': 'prevent', + 'tap': 'allowed', + 'click': 'allowed' }, prevent(e) { e.preventDefault(); - console.log('prevented!'); + console.log('prevented?: ' + e.type + ' ' + e.defaultPrevented); + }, + allowed(e) { + console.log(e.type + ' allowed'); } });