loleaflet/src/control/Control.Scroll.js | 1 loleaflet/src/layer/AnnotationManager.js | 34 +++++++++++++++++----------- loleaflet/src/layer/tile/GridLayer.js | 14 ++++++----- loleaflet/src/layer/tile/WriterTileLayer.js | 6 ++++ loleaflet/src/map/Map.js | 7 ++++- 5 files changed, 42 insertions(+), 20 deletions(-)
New commits: commit 2b49c794e0cf244be23505bada0dc1ebe4921444 Author: Henry Castro <hcas...@collabora.com> Date: Wed Apr 19 11:47:45 2017 -0400 loleaflet: extend document size to scroll annotations Change-Id: I9581818628c365587a4a115b9d3f0b457b8a6905 Reviewed-on: https://gerrit.libreoffice.org/36699 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> diff --git a/loleaflet/src/control/Control.Scroll.js b/loleaflet/src/control/Control.Scroll.js index 3d076f34..d47d422e 100644 --- a/loleaflet/src/control/Control.Scroll.js +++ b/loleaflet/src/control/Control.Scroll.js @@ -29,6 +29,7 @@ L.Control.Scroll = L.Control.extend({ axis: 'yx', theme: 'minimal-dark', scrollInertia: 0, + advanced:{autoExpandHorizontalScroll: true}, /* weird bug, it should be false */ callbacks:{ onScroll: function() { control._onScrollEnd(this); diff --git a/loleaflet/src/layer/AnnotationManager.js b/loleaflet/src/layer/AnnotationManager.js index fc7d077c..54f3496b 100644 --- a/loleaflet/src/layer/AnnotationManager.js +++ b/loleaflet/src/layer/AnnotationManager.js @@ -6,14 +6,16 @@ L.AnnotationManager = L.Class.extend({ options: { marginX: 50, marginY: 10, - offset: 5 + offset: 5, + extraSize: L.point(250, 0) }, - initialize: function (map) { + initialize: function (map, options) { this._map = map; this._items = []; this._selected = null; this._animation = new L.PosAnimation(); + L.setOptions(this, options); this._arrow = L.polyline([], {color: 'darkblue', weight: 1}); this._map.on('zoomend', this._onAnnotationZoom, this); this._map.on('AnnotationCancel', this._onAnnotationCancel, this); @@ -99,7 +101,10 @@ L.AnnotationManager = L.Class.extend({ this.adjustComment(comment); this._items.push(L.annotation(this._map.options.maxBounds.getSouthEast(), comment).addTo(this._map)); } - this.layout(); + if (this._items.length > 0) { + this._map._docLayer._updateMaxBounds(true); + this.layout(); + } }, fillChanges: function(redlines) { @@ -110,7 +115,10 @@ L.AnnotationManager = L.Class.extend({ this.adjustRedLine(changecomment); this._items.push(L.annotation(this._map.options.maxBounds.getSouthEast(), changecomment).addTo(this._map)); } - this.layout(); + if (this._items.length > 0) { + this._map._docLayer._upateMaxBounds(true); + this.layout(); + } }, getItem: function (id) { @@ -190,12 +198,11 @@ L.AnnotationManager = L.Class.extend({ update: function () { if (this._selected) { - var point0, point1, point2; - var topRight = this._map.project(this._map.options.maxBounds.getNorthEast()); - point0 = this._map._docLayer._twipsToPixels(this._selected._data.anchorPos.max); - point1 = L.point(point0.x, point0.y + this.options.offset); - point2 = L.point(topRight.x, point1.y); - this._arrow.setLatLngs([this._map.unproject(point0), this._map.unproject(point1), this._map.unproject(point2)]); + var point; + var scale = this._map.getZoomScale(this._map.getZoom(), 10); + var docRight = this._map.project(this._map.options.maxBounds.getNorthEast()).subtract(this.options.extraSize.multiplyBy(scale)); + point = this._map._docLayer._twipsToPixels(this._selected._data.anchorPos.min); + this._arrow.setLatLngs([this._map.unproject(point), map.unproject(L.point(docRight.x, point.y))]); this._map.addLayer(this._arrow); } else { this._map.removeLayer(this._arrow); @@ -270,7 +277,8 @@ L.AnnotationManager = L.Class.extend({ }, layout: function (zoom) { - var docRight = this._map.project(this._map.options.maxBounds.getNorthEast()); + var scale = this._map.getZoomScale(this._map.getZoom(), 10); + var docRight = this._map.project(this._map.options.maxBounds.getNorthEast()).subtract(this.options.extraSize.multiplyBy(scale)); var topRight = docRight.add(L.point(this.options.marginX, this.options.marginY)); var latlng, layoutBounds, point, index; if (this._selected) { @@ -591,6 +599,6 @@ L.Map.include({ }); -L.annotationManager = function (map) { - return new L.AnnotationManager(map); +L.annotationManager = function (map, options) { + return new L.AnnotationManager(map, options); }; diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js index 8076abb0..f61d50c4 100644 --- a/loleaflet/src/layer/tile/GridLayer.js +++ b/loleaflet/src/layer/tile/GridLayer.js @@ -363,13 +363,14 @@ L.GridLayer = L.Layer.extend({ this._tileHeightTwips = Math.round(this.options.tileHeightTwips * factor); }, - _updateMaxBounds: function (sizeChanged) { + _updateMaxBounds: function (sizeChanged, extraSize, options) { if (this._docWidthTwips === undefined || this._docHeightTwips === undefined) { return; } var docPixelLimits = new L.Point(this._docWidthTwips / this.options.tileWidthTwips, - this._docHeightTwips / this.options.tileHeightTwips); - docPixelLimits = docPixelLimits.multiplyBy(this._tileSize); + this._docHeightTwips / this.options.tileHeightTwips); + docPixelLimits = extraSize ? docPixelLimits.multiplyBy(this._tileSize).add(extraSize) : + docPixelLimits.multiplyBy(this._tileSize); var scale = this._map.getZoomScale(this._map.getZoom(), 10); var topLeft = new L.Point(0, 0); @@ -379,12 +380,13 @@ L.GridLayer = L.Layer.extend({ if (this._documentInfo === '' || sizeChanged) { // we just got the first status so we need to center the document - this._map.setMaxBounds(new L.LatLngBounds(topLeft, bottomRight)); + this._map.setMaxBounds(new L.LatLngBounds(topLeft, bottomRight), options); } var scrollPixelLimits = new L.Point(this._docWidthTwips / this._tileWidthTwips, - this._docHeightTwips / this._tileHeightTwips); - scrollPixelLimits = scrollPixelLimits.multiplyBy(this._tileSize); + this._docHeightTwips / this._tileHeightTwips); + scrollPixelLimits = extraSize ? scrollPixelLimits.multiplyBy(this._tileSize).add(extraSize.multiplyBy(scale)) : + scrollPixelLimits.multiplyBy(this._tileSize); this._docPixelSize = {x: scrollPixelLimits.x, y: scrollPixelLimits.y}; this._map.fire('docsize', {x: scrollPixelLimits.x, y: scrollPixelLimits.y}); }, diff --git a/loleaflet/src/layer/tile/WriterTileLayer.js b/loleaflet/src/layer/tile/WriterTileLayer.js index 8e5edcb3..b45f584d 100644 --- a/loleaflet/src/layer/tile/WriterTileLayer.js +++ b/loleaflet/src/layer/tile/WriterTileLayer.js @@ -227,5 +227,11 @@ L.WriterTileLayer = L.TileLayer.extend({ }); this._resetPreFetching(true); this._update(); + }, + + _updateMaxBounds: function (sizeChanged) { + var extraSize = this._annotations && this._annotations._items.length > 0 ? + this._annotations.options.extraSize : null; + L.GridLayer.prototype._updateMaxBounds.call(this, sizeChanged, extraSize, {panInside: false}); } }); diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js index af9f7233..3a2ce54d 100644 --- a/loleaflet/src/map/Map.js +++ b/loleaflet/src/map/Map.js @@ -278,10 +278,11 @@ L.Map = L.Evented.extend({ return this.fire('moveend'); }, - setMaxBounds: function (bounds) { + setMaxBounds: function (bounds, options) { bounds = L.latLngBounds(bounds); this.options.maxBounds = bounds; + options = options || {}; if (!bounds) { return this.off('moveend', this._panInsideMaxBounds); @@ -291,6 +292,10 @@ L.Map = L.Evented.extend({ this._panInsideMaxBounds(); } + if (options.panInside === false) { + return this.off('moveend', this._panInsideMaxBounds); + } + return this.on('moveend', this._panInsideMaxBounds); }, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits