Codebase list leaflet / c56e376
bring back the horrible timeout hack for Android, close #1785 Vladimir Agafonkin 10 years ago
1 changed file(s) with 15 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
198198 return e;
199199 },
200200
201 // this solves a bug in Android WebView where a single touch triggers two click events.
201 // this is a horrible workaround for a bug in Android where a single touch triggers two click events
202202 _filterClick: function (e, handler) {
203 // check if click is simulated on the element, and if it is, reject any non-simulated events
204 if (e.target._simulatedClick && !e._simulated) { return; }
203 var timeStamp = (e.timeStamp || e.originalEvent.timeStamp),
204 elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);
205
206 // are they closer together than 1000ms yet more than 100ms?
207 // Android typically triggers them ~300ms apart while multiple listeners
208 // on the same event should be triggered far faster;
209 // or check if click is simulated on the element, and if it is, reject any non-simulated events
210
211 if ((elapsed && elapsed > 100 && elapsed < 1000) || (e.target._simulatedClick && !e._simulated)) {
212 L.DomEvent.stop(e);
213 return;
214 }
215 L.DomEvent._lastClick = timeStamp;
216
205217 return handler(e);
206218 }
207219 };