diff --git a/js/util/LeafletPatches.js b/js/util/LeafletPatches.js new file mode 100644 index 0000000..bfdae9c --- /dev/null +++ b/js/util/LeafletPatches.js @@ -0,0 +1,16 @@ +// Fixes wrong added offset when dragging, which can leave mouse off the marker +// after dragging and cause a map click +// see https://github.com/Leaflet/Leaflet/pull/7446 +// see https://github.com/Leaflet/Leaflet/issues/4457 +L.Draggable.prototype._onMoveOrig = L.Draggable.prototype._onMove; +L.Draggable.prototype._onMove = function (e) { + var start = !this._moved; + + this._onMoveOrig.call(this, e); + + if (start && this._moved) { + var offset = this._newPos.subtract(this._startPos); + this._startPos = this._startPos.add(offset); + this._newPos = this._newPos.add(offset); + } +};