[Libreoffice-commits] online.git: loleaflet/plugins loleaflet/src

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Feb 26 13:26:28 UTC 2019


 loleaflet/plugins/path-transform/src/Path.Drag.js |    9 +++++--
 loleaflet/src/layer/tile/TileLayer.js             |    5 ++++
 loleaflet/src/layer/vector/SVGGroup.js            |   26 +++++++++++++++++++---
 3 files changed, 35 insertions(+), 5 deletions(-)

New commits:
commit ecdd81c6584b2e75d40c1602d0cb183e29690b87
Author:     Marco Cecchetti <mrcekets at gmail.com>
AuthorDate: Sun Feb 24 17:59:16 2019 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Feb 26 14:26:10 2019 +0100

    online: calc: selecting a chart element; impress: move caret by clicking
    
    Clicking on individual chart elements doesn't select any object.
    Better forwarding of single click when there is no drag action.
    Start to display the svg preview for moved shapes images on first
    mousemove event instead of mousedown. For text object, on editing,
    this avoids to see the old text content when user clicks for changing
    the cursor position.
    
    This patch solve also the following impress issue: moving caret around
    in text box by clicking around doesn't work
    
    Change-Id: I316c7a92667bda8fa1e115bcc848b474cbc40242
    Reviewed-on: https://gerrit.libreoffice.org/68314
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
    Tested-by: Szymon Kłos <szymon.klos at collabora.com>
    (cherry picked from commit bbb6d34ac20efc3c05dc6dcd508962091f99fd52)
    Reviewed-on: https://gerrit.libreoffice.org/68313

diff --git a/loleaflet/plugins/path-transform/src/Path.Drag.js b/loleaflet/plugins/path-transform/src/Path.Drag.js
index 36acdd8b1..04ab67373 100644
--- a/loleaflet/plugins/path-transform/src/Path.Drag.js
+++ b/loleaflet/plugins/path-transform/src/Path.Drag.js
@@ -107,6 +107,7 @@ L.Handler.PathDrag = L.Handler.extend(/** @lends  L.Path.Drag.prototype */ {
 	_onDragStart: function(evt) {
 		var eventType = evt.originalEvent._simulated ? 'touchstart' : evt.originalEvent.type;
 
+		this._mouseDown = evt.originalEvent;
 		this._mapDraggingWasEnabled = false;
 		this._startPoint = evt.containerPoint.clone();
 		this._dragStartPoint = evt.containerPoint.clone();
@@ -184,6 +185,7 @@ L.Handler.PathDrag = L.Handler.extend(/** @lends  L.Path.Drag.prototype */ {
 	* @param  {L.MouseEvent} evt
 	*/
 	_onDragEnd: function(evt) {
+		L.DomEvent.stop(evt);
 		var containerPoint = this._path._map.mouseEventToContainerPoint(evt);
 		var moved = this.moved();
 
@@ -193,8 +195,6 @@ L.Handler.PathDrag = L.Handler.extend(/** @lends  L.Path.Drag.prototype */ {
 			this._path._updatePath();
 			this._path._project();
 			this._path._transform(null);
-
-			L.DomEvent.stop(evt);
 		}
 
 		L.DomEvent.off(document, 'mousemove touchmove', this._onDrag,    this);
@@ -226,6 +226,11 @@ L.Handler.PathDrag = L.Handler.extend(/** @lends  L.Path.Drag.prototype */ {
 			if (moved) L.DomEvent._fakeStop({ type: 'click' });
 			this._path._map.dragging.enable();
 		}
+
+		if (!moved) {
+			this._path._map._handleDOMEvent(this._mouseDown);
+			this._path._map._handleDOMEvent(evt)
+		}
 	},
 
 
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 853d7e7be..cffd800bf 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1800,6 +1800,11 @@ L.TileLayer = L.GridLayer.extend({
 		}
 		else if (e.type === 'graphicmoveend') {
 			var deltaPos = aPos.subtract(this._graphicMarker._startPos);
+			if (deltaPos.x === 0 && deltaPos.y === 0) {
+				this._graphicMarker.isDragged = false;
+				return;
+			}
+
 			var newPos = this._graphicSelectionTwips.min.add(deltaPos);
 			var size = this._graphicSelectionTwips.getSize();
 
diff --git a/loleaflet/src/layer/vector/SVGGroup.js b/loleaflet/src/layer/vector/SVGGroup.js
index c9548e347..c719a7b1a 100644
--- a/loleaflet/src/layer/vector/SVGGroup.js
+++ b/loleaflet/src/layer/vector/SVGGroup.js
@@ -42,8 +42,9 @@ L.SVGGroup = L.Layer.extend({
 	_onDragStart: function(evt) {
 		if (!this._dragShape)
 			return;
+		this._moved = false;
 
-		this._showEmbeddedSVG();
+		L.DomEvent.on(this._dragShape, 'mousemove', this._onDrag, this);
 		L.DomEvent.on(this._dragShape, 'mouseup', this._onDragEnd, this);
 
 		var data = {
@@ -56,16 +57,35 @@ L.SVGGroup = L.Layer.extend({
 		this.fire('graphicmovestart', {pos: pos});
 	},
 
-	_onDragEnd: function(evt) {
+	_onDrag: function(evt) {
 		if (!this._dragShape)
 			return;
 
+		if (!this._moved) {
+			this._moved = true;
+			this._showEmbeddedSVG();
+		}
+
+		var data = {
+			originalEvent: evt,
+			containerPoint: this._map.mouseEventToContainerPoint(evt)
+		};
+		this.dragging._onDrag(data);
+
+	},
+
+	_onDragEnd: function(evt) {
+		if (!this._dragShape)
+			return;
+		L.DomEvent.off(this._dragShape, 'mousemove', this._onDrag, this);
 		L.DomEvent.off(this._dragShape, 'mouseup', this._onDragEnd, this);
-		this.dragging._onDragEnd(evt);
 
+		this._moved = false;
 		this._hideEmbeddedSVG();
 		var pos = this._map.mouseEventToLatLng(evt);
 		this.fire('graphicmoveend', {pos: pos});
+
+		this.dragging._onDragEnd(evt);
 	},
 
 	bringToFront: function () {


More information about the Libreoffice-commits mailing list