[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-7' - loleaflet/src

Miklos Vajna vmiklos at collabora.co.uk
Thu Jan 21 08:02:48 PST 2016


 loleaflet/src/layer/tile/TileLayer.js |   12 ++++++++++++
 1 file changed, 12 insertions(+)

New commits:
commit a32b32a756fb2dbb5b5889d69b092d48c5a0ab69
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 21 16:54:11 2016 +0100

    leaflet: position cursor before image drop
    
    So we insert the image (close to or even exactly) at the drop position,
    instead of the last cursor position, which may be far away.
    
    With this, we're closer to the desktop image drop behavior in the
    browser.
    
    (cherry picked from commit 6fb558741cec29af5cb32edc864ae0bece82e619)

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index bae33d6..090d15a 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1013,6 +1013,9 @@ L.TileLayer = L.GridLayer.extend({
 	},
 
 	_onDrop: function (e) {
+		// The original event doesn't contain the coordinates.
+		var latlng = e.latlng;
+
 		e = e.originalEvent;
 		e.preventDefault();
 
@@ -1041,6 +1044,15 @@ 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) {


More information about the Libreoffice-commits mailing list