From f7d4a2cfa1554431325095f752ffecd3cc539400 Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Mon, 25 Jan 2016 12:32:50 +0100 Subject: [PATCH] loleaflet: Position the mouse with 'drop' always (even html snippet). --- loleaflet/src/layer/tile/TileLayer.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 22d830610..71855f52e 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -1051,8 +1051,15 @@ L.TileLayer = L.GridLayer.extend({ }, _onDrop: function (e) { - // The original event doesn't contain the coordinates. + // Move the cursor, so that the insert position is as close to the drop coordinates as possible. var latlng = e.latlng; + var docLayer = this._map._docLayer; + var mousePos = docLayer._latLngToTwips(latlng); + var count = 1; + var buttons = 1; + var modifier = this._map.keyboard.modifier; + this._postMouseEvent('buttondown', mousePos.x, mousePos.y, count, buttons, modifier); + this._postMouseEvent('buttonup', mousePos.x, mousePos.y, count, buttons, modifier); e = e.originalEvent; e.preventDefault(); @@ -1082,15 +1089,6 @@ L.TileLayer = L.GridLayer.extend({ for (var i = 0; i < files.length; ++i) { var file = files[i]; if (file.type.match(/image.*/)) { - // Move the cursor, so that the insert position is as close to the drop coordinates as possible. - var docLayer = this._map._docLayer; - var mousePos = docLayer._latLngToTwips(latlng); - var count = 1; - var buttons = 1; - var modifier = this._map.keyboard.modifier; - this._postMouseEvent('buttondown', mousePos.x, mousePos.y, count, buttons, modifier); - this._postMouseEvent('buttonup', mousePos.x, mousePos.y, count, buttons, modifier); - var reader = new FileReader(); var socket = this._map._socket; reader.onload = (function(aImg) {