Skip to content

Commit

Permalink
Do not set touchend listeners to passive
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
dfreedm committed Nov 29, 2017
1 parent 2762760 commit 84fa3bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/utils/gestures.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down
10 changes: 8 additions & 2 deletions test/smoke/passive-gestures.html
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
});
</script>
Expand Down

0 comments on commit 84fa3bf

Please sign in to comment.