[Libreoffice-commits] online.git: loleaflet/src
Mihai Varga
mihai.varga at collabora.com
Fri Nov 20 00:47:07 PST 2015
loleaflet/src/map/handler/Map.Mouse.js | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
New commits:
commit 8df7659ccd7c4f194a14de71b2cb02fd3769eb25
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Nov 20 10:45:54 2015 +0200
loleaflet: ccu#1328 added image/shape movement preview
diff --git a/loleaflet/src/map/handler/Map.Mouse.js b/loleaflet/src/map/handler/Map.Mouse.js
index 2520c7c..07ddf8e 100644
--- a/loleaflet/src/map/handler/Map.Mouse.js
+++ b/loleaflet/src/map/handler/Map.Mouse.js
@@ -11,6 +11,7 @@ L.Map.Mouse = L.Handler.extend({
initialize: function (map) {
this._map = map;
this._mouseEventsQueue = [];
+ this._prevMousePos = null;
},
addHooks: function () {
@@ -40,8 +41,35 @@ L.Map.Mouse = L.Handler.extend({
if (!docLayer || (this._map.slideShow && this._map.slideShow.fullscreen)) {
return;
}
- if (docLayer._graphicMarker && docLayer._graphicMarker.isDragged) {
- return;
+ if (docLayer._graphicMarker) {
+ if (docLayer._graphicMarker.isDragged) {
+ return;
+ }
+ if (!docLayer._isEmptyRectangle(docLayer._graphicSelection) &&
+ docLayer._graphicMarker.getBounds().contains(e.latlng)) {
+ // if we have a graphic selection and the user clicks inside the rectangle
+ if (e.type === 'mousedown') {
+ 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 === 'mouseup') {
+ this._prevMousePos = null;
+ }
+ }
}
for (var key in docLayer._selectionHandles) {
More information about the Libreoffice-commits
mailing list