PERF: Disable ember touchstart listener (#15112)
Registering non-passive listeners for the touchstart event can affect scroll performance on mobile devices, and now shows a warning in Chrome. Our current version of Ember unconditionally registers all event listeners, even if they're unused. It also doesn't support passive event listeners. Once we get to Ember 4.0, it lazily registers event listeners, and supports passive listeners via the `{{on` helper. We already disable the ember `mousemove` and `touchmove` events for performance, so it makes sense to do the same for `touchstart`. We are not using `touchstart` anywhere in core, and I cannot find any official/unofficial plugins which use it. If a `touchstart` event is required, plugins/themes can always register their own listeners (preferably on a specific element, rather than the whole `document`)
This commit is contained in:
parent
fac6cc0778
commit
e8bb37bd89
|
@ -5,14 +5,13 @@ export default {
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
// By default Ember listens to too many events. This tells it the only events
|
// By default Ember listens to too many events. This tells it the only events
|
||||||
// we're interested in. (it removes mousemove and touchmove)
|
// we're interested in. (it removes mousemove, touchstart and touchmove)
|
||||||
if (initializedOnce) {
|
if (initializedOnce) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ember.EventDispatcher.reopen({
|
Ember.EventDispatcher.reopen({
|
||||||
events: {
|
events: {
|
||||||
touchstart: "touchStart",
|
|
||||||
touchend: "touchEnd",
|
touchend: "touchEnd",
|
||||||
touchcancel: "touchCancel",
|
touchcancel: "touchCancel",
|
||||||
keydown: "keyDown",
|
keydown: "keyDown",
|
||||||
|
|
Loading…
Reference in New Issue