From 84a69e0af1c6b1e36d4c1858470707c67e6547f0 Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Fri, 21 May 2021 09:17:33 +0200 Subject: [PATCH] Patch Leaflet drag offset bug --- js/util/LeafletPatches.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 js/util/LeafletPatches.js 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); + } +};