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

Marco Cecchetti marco.cecchetti at collabora.com
Wed Aug 2 10:58:23 UTC 2017


 loleaflet/src/map/handler/Map.Mouse.js |   34 +++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

New commits:
commit 67de89cbbc238b12b1064a2107967caecd9f126c
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Tue Aug 1 17:51:27 2017 +0200

    loleaflet: graphic selection can get misplaced if mouse is moved fast
    
    Change-Id: I2c1893110ce76bed2c822c8d1ddd293c8f627307
    Reviewed-on: https://gerrit.libreoffice.org/40644
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/map/handler/Map.Mouse.js b/loleaflet/src/map/handler/Map.Mouse.js
index b5861ff1..78229005 100644
--- a/loleaflet/src/map/handler/Map.Mouse.js
+++ b/loleaflet/src/map/handler/Map.Mouse.js
@@ -45,25 +45,27 @@ L.Map.Mouse = L.Handler.extend({
 			if (docLayer._graphicMarker.isDragged) {
 				return;
 			}
-			if (!docLayer._isEmptyRectangle(docLayer._graphicSelection) &&
-					docLayer._graphicMarker.getBounds().contains(e.latlng)) {
+			if (!docLayer._isEmptyRectangle(docLayer._graphicSelection)) {
 				// if we have a graphic selection and the user clicks inside the rectangle
-				if (e.type === 'mousedown') {
+				var isInside = docLayer._graphicMarker.getBounds().contains(e.latlng);
+				if (e.type === 'mousedown' && isInside) {
 					this._prevMousePos = e.latlng;
 				}
-				else if (e.type === 'mousemove' && this._mouseDown && !this._prevMousePos) {
-					// if the user started to drag the shape before the selection
-					// has been drawn
-					this._prevMousePos = e.latlng;
-				}
-				else if (e.type === 'mousemove' && this._prevMousePos) {
-					// we have a graphic selection and the user started to drag it
-					var delta = L.latLng(e.latlng.lat - this._prevMousePos.lat, e.latlng.lng - this._prevMousePos.lng);
-					this._prevMousePos = e.latlng;
-					var oldSelectionCenter = docLayer._graphicMarker.getBounds().getCenter();
-					var newSelectionCenter = L.latLng(oldSelectionCenter.lat + delta.lat, oldSelectionCenter.lng + delta.lng);
-					if (docLayer._graphicMarker.editing) {
-						docLayer._graphicMarker.editing._move(newSelectionCenter);
+				else if (e.type === 'mousemove' && this._mouseDown) {
+					if (!this._prevMousePos && isInside) {
+						// if the user started to drag the shape before the selection
+						// has been drawn
+						this._prevMousePos = e.latlng;
+					}
+					else {
+						// we have a graphic selection and the user started to drag it
+						var delta = L.latLng(e.latlng.lat - this._prevMousePos.lat, e.latlng.lng - this._prevMousePos.lng);
+						this._prevMousePos = e.latlng;
+						var oldSelectionCenter = docLayer._graphicMarker.getBounds().getCenter();
+						var newSelectionCenter = L.latLng(oldSelectionCenter.lat + delta.lat, oldSelectionCenter.lng + delta.lng);
+						if (docLayer._graphicMarker.editing) {
+							docLayer._graphicMarker.editing._move(newSelectionCenter);
+						}
 					}
 				}
 				else if (e.type === 'mouseup') {


More information about the Libreoffice-commits mailing list