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

Henry Castro hcastro at collabora.com
Sun Sep 25 16:46:37 UTC 2016


 loleaflet/src/layer/marker/Cursor.js  |   21 +++++++--------------
 loleaflet/src/layer/tile/TileLayer.js |   14 +++++++++++---
 2 files changed, 18 insertions(+), 17 deletions(-)

New commits:
commit 23b27920535675e2ca09ac549b96edf2cf291ecc
Author: Henry Castro <hcastro at collabora.com>
Date:   Sun Sep 25 12:42:32 2016 -0400

    loleaflet: improve cursor, hide view cursor if same position

diff --git a/loleaflet/src/layer/marker/Cursor.js b/loleaflet/src/layer/marker/Cursor.js
index 78706e0..1335e8e 100644
--- a/loleaflet/src/layer/marker/Cursor.js
+++ b/loleaflet/src/layer/marker/Cursor.js
@@ -13,6 +13,7 @@ L.Cursor = L.Layer.extend({
 		L.setOptions(this, options);
 		this._latlng = L.latLng(latlng);
 		this._size = L.point(size);
+		this._initLayout();
 	},
 
 	onAdd: function () {
@@ -57,6 +58,12 @@ L.Cursor = L.Layer.extend({
 		return this;
 	},
 
+	setOpacity: function (opacity) {
+		if (this._container) {
+			L.DomUtil.setOpacity(this._cursor, opacity);
+		}
+	},
+
 	_initLayout: function () {
 		this._container = L.DomUtil.create('div', 'leaflet-cursor-container');
 		if (this.options.header) {
@@ -88,20 +95,6 @@ L.Cursor = L.Layer.extend({
 		this._container.style.zIndex = this.options.zIndex;
 	},
 
-	setOpacity: function (opacity) {
-		this.options.opacity = opacity;
-		if (this._map) {
-			this._updateOpacity();
-		}
-
-		return this;
-	},
-
-	_updateOpacity: function () {
-		var opacity = this.options.opacity;
-		L.DomUtil.setOpacity(this._container, opacity);
-	},
-
 	_setSize: function () {
 		this._cursor.style.height = this._size.y + 'px';
 		this._container.style.top = '-' + (this._container.clientHeight - this._size.y - 2) / 2 + 'px';
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 788a962..047a40d 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1177,6 +1177,13 @@ L.TileLayer = L.GridLayer.extend({
 			this._map.removeLayer(this._cursorMarker);
 			this._isCursorOverlayVisible = false;
 		}
+
+		this.eachView(this._viewCursors, function (item) {
+			var viewCursorMarker = item.marker;
+			if (viewCursorMarker) {
+				viewCursorMarker.setOpacity(this._map.hasLayer(this._cursorMarker) && this._cursorMarker.getLatLng().equals(viewCursorMarker.getLatLng()) ? 0 : 1);
+			}
+		}, this, true);
 	},
 
 	// Update colored non-blinking view cursor
@@ -1210,6 +1217,7 @@ L.TileLayer = L.GridLayer.extend({
 			else {
 				viewCursorMarker.setLatLng(viewCursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())));
 			}
+			viewCursorMarker.setOpacity(this._map.hasLayer(this._cursorMarker) && this._cursorMarker.getLatLng().equals(viewCursorMarker.getLatLng()) ? 0 : 1);
 			this._viewLayerGroup.addLayer(viewCursorMarker);
 		}
 		else if (viewCursorMarker) {
@@ -1274,9 +1282,9 @@ L.TileLayer = L.GridLayer.extend({
 		}
 	},
 
-	eachView: function (view, method, context) {
-		for (var key in view) {
-			method.call(context, key);
+	eachView: function (views, method, context, item) {
+		for (var key in views) {
+			method.call(context, item ? views[key] : key);
 		}
 	},
 


More information about the Libreoffice-commits mailing list