Reputation: 461
Recently Chrome started emitting the following warnings:
[Violation] Added non-passive event listener to a scroll-blocking 'touchmove' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
These are coming from the JavaScript Google Maps API code. I'm able to add {passive: true} to addEventListener() in my own code but don't know how to suppress the warning in Googles libraries?
Upvotes: 44
Views: 5261
Reputation: 3209
this works for me. Got here https://stackoverflow.com/a/55388961/2233069
(function () {
if (typeof EventTarget !== "undefined") {
let func = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function (type, fn, capture) {
this.func = func;
if(typeof capture !== "boolean"){
capture = capture || {};
capture.passive = false;
}
this.func(type, fn, capture);
};
};
}());
Upvotes: 1
Reputation: 46
There is nothing you can do at this point. It's a warning that is generated from Googles own API code. As long as your own event listeners are passive, I think it can be safely ignored.
Upvotes: 0