Skip to content

Commit 84fa3bf

Browse files
committed
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
1 parent 2762760 commit 84fa3bf

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/utils/gestures.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@
481481
gobj[dep] = gd = {_count: 0};
482482
}
483483
if (gd._count === 0) {
484-
let options = !isMouseEvent(dep) && PASSIVE_TOUCH();
484+
let options = !isMouseEvent(dep) && dep !== 'touchend' && PASSIVE_TOUCH();
485485
node.addEventListener(dep, this._handleNative, options);
486486
}
487487
gd[name] = (gd[name] || 0) + 1;
@@ -515,7 +515,7 @@
515515
gd[name] = (gd[name] || 1) - 1;
516516
gd._count = (gd._count || 1) - 1;
517517
if (gd._count === 0) {
518-
let options = !isMouseEvent(dep) && PASSIVE_TOUCH();
518+
let options = !isMouseEvent(dep) && dep !== 'touchend' && PASSIVE_TOUCH();
519519
node.removeEventListener(dep, this._handleNative, options);
520520
}
521521
}

test/smoke/passive-gestures.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,17 @@
4040
is: 'x-passive',
4141
listeners: {
4242
'down': 'prevent',
43-
'move': 'prevent'
43+
'move': 'prevent',
44+
'up': 'prevent',
45+
'tap': 'allowed',
46+
'click': 'allowed'
4447
},
4548
prevent(e) {
4649
e.preventDefault();
47-
console.log('prevented!');
50+
console.log('prevented?: ' + e.type + ' ' + e.defaultPrevented);
51+
},
52+
allowed(e) {
53+
console.log(e.type + ' allowed');
4854
}
4955
});
5056
</script>

0 commit comments

Comments
 (0)