Leaflet / Leaflet.draw

Vector drawing and editing plugin for Leaflet
https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html
MIT License
1.97k stars 992 forks source link

Panning the map in draw mode adds node into my polyline/polygon #729

Open doubotis opened 7 years ago

doubotis commented 7 years ago

How to reproduce

What behaviour I'm expecting and which behaviour I'm seeing

Minimal example reproducing the issue

Try to pan the map when in drawing mode. Your example: http://leaflet.github.io/Leaflet.draw/docs/examples/full.html

Old version, expected behavior: https://jsfiddle.net/user2314737/Lscupxqp/

Additional information

This behavior was not observed in previous versions (with Leaflet 1.0.0 / L.Draw 0.2.3 it seems to work well)

I've searching in the code and it appears touchstart event is called before mouse events. That means mouseup/mousedown events are "ignored". Well, okay, but why touchstart event triggers the adding of a node? The node must be added when touchend triggers, not before.

I tried to add a "touchend" event on the map, but seems that doesn't work. map.on("touchend touchcancel", function(e) { console.log(e); }); doesn't log anything.

Maybe an issue with Leaflet itself ?

TheVoxell commented 7 years ago

Same issue here :)

federicoalvarez-github commented 7 years ago

same here

goflo commented 7 years ago

I have the same issue. There is already an issue for that: https://github.com/Leaflet/Leaflet.draw/issues/695 There is also an workaround (overriding the L.Draw.Polyline.prototype._onTouch) included which works fine for me.

johnd0e commented 4 years ago

Possible fix: https://github.com/Leaflet/Leaflet.draw/issues/935#issuecomment-577151194