loleaflet: fix: can't drag images between pages

The problem seems to be that the preview arrives with a not so small
delay, when the user has already started to perform a new dragging:

1) the drag starts using the transparent rectangle to which is
attached (on drag start) the _onDragEnd handler
2) the user sees moving only the selection rectangle
3) the svg preview arrives in the middle of dragging overwriting the
transparent rectangle element
4) when dragging ends _onDragEnd is not invoked since the transparent
rectangle has been discarded in favor of the svg preview

It is possible to avoid the step (3) to occur by checking if the
dragging is already started. In this case _onDragEnd is invoked and
the TransformDialog UNO command is sent. So, even with a delay the
image position will be finally updated.

Change-Id: Ifefd46f470b090089385083e4e2d643eb8e7017c
This commit is contained in:
Marco Cecchetti 2019-10-03 21:33:27 +02:00
parent 1bff9e7bf8
commit eca2a7ce4d

View file

@ -36,7 +36,7 @@ L.SVGGroup = L.Layer.extend({
var size = L.bounds(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),
this._map.latLngToLayerPoint(this._bounds.getSouthEast())).getSize();
if (doc.lastChild.localName !== 'svg')
if (doc.lastChild.localName !== 'svg' || this._dragStarted)
return;
if (svgString.indexOf('XTEXT_PAINTSHAPE_BEGIN') !== -1) {
@ -63,7 +63,7 @@ L.SVGGroup = L.Layer.extend({
_onDragStart: function(evt) {
if (!this._map || !this._dragShape || !this.dragging)
return;
this._dragStarted = true;
this._moved = false;
if (!this.options.manualDrag) {
@ -116,6 +116,7 @@ L.SVGGroup = L.Layer.extend({
if (this.options.manualDrag || evt.type === 'mouseup')
this.dragging._onDragEnd(evt);
this._dragStarted = false;
},
bringToFront: function () {
@ -141,6 +142,7 @@ L.SVGGroup = L.Layer.extend({
},
onAdd: function () {
this._dragStarted = false;
this._renderer = this._map.getRenderer(this);
this._renderer._initGroup(this);
this._renderer._initPath(this._rect);