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

Marco Cecchetti marco.cecchetti at collabora.com
Fri Feb 19 10:21:30 UTC 2016


 loleaflet/src/layer/tile/TileLayer.js |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

New commits:
commit 049633a6445084271ecd9cd0289d36de60068395
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Thu Feb 18 15:30:19 2016 +0100

    loleaflet - user view does not follow the cell cursor
    
    Change-Id: I7e877847de0c2c644948b47daa0bff0e5f7da3a0
    Reviewed-on: https://gerrit.libreoffice.org/22489
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index ad6567e..d3c1425 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -931,6 +931,30 @@ L.TileLayer = L.GridLayer.extend({
 
 	_onUpdateCellCursor: function () {
 		if (this._cellCursor && !this._isEmptyRectangle(this._cellCursor)) {
+			var mapBounds = this._map.getBounds();
+			if (!mapBounds.contains(this._cellCursor)) {
+				var spacingX = Math.abs((this._cellCursor.getEast() - this._cellCursor.getWest())) / 4.0;
+				var spacingY = Math.abs((this._cellCursor.getSouth() - this._cellCursor.getNorth())) / 4.0;
+				var scrollX = 0, scrollY = 0;
+				if (this._cellCursor.getWest() < mapBounds.getWest()) {
+					scrollX = this._cellCursor.getWest() - mapBounds.getWest() - spacingX;
+				} else if (this._cellCursor.getEast() > mapBounds.getEast()) {
+					scrollX = this._cellCursor.getEast() - mapBounds.getEast() + spacingX;
+				} else if (this._cellCursor.getNorth() > mapBounds.getNorth()) {
+					scrollY = this._cellCursor.getNorth() - mapBounds.getNorth() + spacingY;
+				} else if (this._cellCursor.getSouth() < mapBounds.getSouth()) {
+					scrollY = this._cellCursor.getSouth() - mapBounds.getSouth() - spacingY;
+				}
+				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) {
 				this._map.removeLayer(this._cellCursorMarker);
 			}


More information about the Libreoffice-commits mailing list