forked from Leaflet/Leaflet.draw
-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
Description
I think this is not an issue with the plugin, but with Leaflet itself and this might be useful to know there is a bug in Leaflet which prevents 'touchend' events from firing when running on mobile devices with touch.
Generally speaking this bug prevents Leaflet.draw from firing '_fireEdit' functions which are responsible for setting layer as edited this will never fire on 'touchend':
_fireEdit: function () {
this._shape.edited = true;
this._shape.fire('edit');
}
I managed to fix the issue by modifying Leaflet (version 0.7.7) source code to fire 'touchend', line 7069.
The original Leaflet function:
function onTouchEnd(e) {
if (L.Browser.pointer) {
var idx = trackedTouches.indexOf(e.pointerId);
if (idx === -1) {
return;
}
trackedTouches.splice(idx, 1);
}
...
}
And here is the fix:
function onTouchEnd(e) {
if (L.Browser.pointer) {
var idx = trackedTouches.indexOf(e.pointerId);
if (idx === -1) {
return;
}
trackedTouches.splice(idx, 1);
}
else if (touch) {
touch.type = 'touchend';
handler(touch);
}
...
}
Edited by @ddproxy to fix code blocks
Reactions are currently unavailable