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

Pranav Kant pranavk at collabora.co.uk
Fri Oct 28 16:28:37 UTC 2016


 loleaflet/src/layer/tile/TileLayer.js |   27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

New commits:
commit 0b594425b0af4d8d92af4054caf1725e210106ba
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Oct 28 21:54:52 2016 +0530

    Make 'scrollto' feature conditional on edit permission
    
    Obviously we didn't intend to remove it for editors.
    
    This partially reverts commit a36440dda36bf62afb1a8daa215a32fb6dd4af92.
    
    Change-Id: Idb9424bf75b96c168338a660189d5a5c7bffa857

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index fb0017c..ae0e085 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -893,8 +893,22 @@ L.TileLayer = L.GridLayer.extend({
 		var pixBounds = L.bounds(this._map.latLngToLayerPoint(this._visibleCursor.getSouthWest()),
 						 this._map.latLngToLayerPoint(this._visibleCursor.getNorthEast()));
 		var cursorPos = this._visibleCursor.getNorthWest();
+
+		if (!e && !this._map.getBounds().contains(this._visibleCursor) && this._isCursorVisible
+		    && this._map._permission === 'edit') {
+			var center = this._map.project(cursorPos);
+			center = center.subtract(this._map.getSize().divideBy(2));
+			center.x = Math.round(center.x < 0 ? 0 : center.x);
+			center.y = Math.round(center.y < 0 ? 0 : center.y);
+
+			if (!(this._selectionHandles.start && this._selectionHandles.start.isDragged) &&
+			    !(this._selectionHandles.end && this._selectionHandles.end.isDragged)) {
+				this._map.fire('scrollto', {x: center.x, y: center.y});
+			}
+		}
+
 		if (this._map._permission !== 'readonly' && this._isCursorVisible && this._isCursorOverlayVisible
-				&& !this._isEmptyRectangle(this._visibleCursor)) {
+		    && !this._isEmptyRectangle(this._visibleCursor)) {
 			if (this._cursorMarker) {
 				this._map.removeLayer(this._cursorMarker);
 			}
@@ -1036,6 +1050,17 @@ L.TileLayer = L.GridLayer.extend({
 				} else if (verticalDirection === -1 && this._cellCursor.getSouth() < mapBounds.getSouth()) {
 					scrollY = this._cellCursor.getSouth() - mapBounds.getSouth() - spacingY;
 				}
+
+				if (this._map._permission === 'edit' && (scrollX !== 0 || scrollY !== 0)) {
+					var newCenter = mapBounds.getCenter();
+					newCenter.lng += scrollX;
+					newCenter.lat += scrollY;
+					var center = this._map.project(newCenter);
+					center = center.subtract(this._map.getSize().divideBy(2));
+					center.x = Math.round(center.x < 0 ? 0 : center.x);
+					center.y = Math.round(center.y < 0 ? 0 : center.y);
+					this._map.fire('scrollto', {x: center.x, y: center.y});
+				}
 			}
 
 			if (this._cellCursorMarker) {


More information about the Libreoffice-commits mailing list