[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-7' - loleaflet/src
Marco Cecchetti
marco.cecchetti at collabora.com
Fri Feb 19 10:21:31 UTC 2016
loleaflet/src/layer/tile/TileLayer.js | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
New commits:
commit 70dd2e55552487286de8c8cbd18d00ca14c9ad23
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/22490
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 c81758e..61e7e7f 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