elmarquis / Leaflet.GestureHandling

Brings the basic functionality of Google Maps Gesture Handling into Leaflet. Prevents users from getting trapped on the map when scrolling a long page.
MIT License
269 stars 60 forks source link

Lighthouse error "passive listeners" #66

Open 2803media opened 3 years ago

2803media commented 3 years ago

Hi the last version generate an error in lighthouse :

Does not use passive listeners to improve scrolling performance

More info here : https://web.dev/uses-passive-event-listeners/?utm_source=lighthouse&utm_medium=devtools

2803media commented 3 years ago

FYI just change thoses lines:

this._map._container.addEventListener("touchstart", this._handleTouch);
this._map._container.addEventListener("touchmove", this._handleTouch);
this._map._container.addEventListener("touchend", this._handleTouch);
this._map._container.addEventListener("touchcancel", this._handleTouch);
this._map._container.addEventListener("click", this._handleTouch);

to

this._map._container.addEventListener("touchstart", this._handleTouch, {passive: true});
this._map._container.addEventListener("touchmove", this._handleTouch, {passive: true});
this._map._container.addEventListener("touchend", this._handleTouch, {passive: true});
this._map._container.addEventListener("touchcancel", this._handleTouch, {passive: true});
this._map._container.addEventListener("click", this._handleTouch, {passive: true});