[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3-0' - loleaflet/src
Aditya Dewan
aditya.dewan at collabora.co.uk
Thu Dec 28 12:16:55 UTC 2017
loleaflet/src/control/Ruler.js | 27 +++++++++++++++++++--------
loleaflet/src/layer/tile/GridLayer.js | 4 ++--
2 files changed, 21 insertions(+), 10 deletions(-)
New commits:
commit 92f013af5be46c6bbb850deebde95ca4eff5f90c
Author: Aditya Dewan <aditya.dewan at collabora.co.uk>
Date: Mon Dec 11 01:15:07 2017 +0530
fix ruler misalignment due to comments
Change-Id: I0d69d6cb1fa57801ee969556a25c89bb9afe9869
(cherry picked from commit 1a191d9cd3370fc4922cd81d37eb4ea92e989349)
Reviewed-on: https://gerrit.libreoffice.org/47134
Reviewed-by: pranavk <pranavk at collabora.co.uk>
Tested-by: pranavk <pranavk at collabora.co.uk>
diff --git a/loleaflet/src/control/Ruler.js b/loleaflet/src/control/Ruler.js
index d13e3cbd..4251c568 100644
--- a/loleaflet/src/control/Ruler.js
+++ b/loleaflet/src/control/Ruler.js
@@ -30,7 +30,9 @@ L.Control.Ruler = L.Control.extend({
return this._initLayout();
},
- _updatePaintTimer: function() {
+ _updatePaintTimer: function(e) {
+ if (e.extraSize)
+ this.options.extraSize = e.extraSize.x;
clearTimeout(this.options.timer);
this.options.timer = setTimeout(L.bind(this._updateBreakPoints, this), 300);
},
@@ -79,11 +81,8 @@ L.Control.Ruler = L.Control.extend({
if (this.options.margin1 == null || this.options.margin2 == null)
return;
- if (this._map._docLayer._annotations._items.length === 0)
+ if (this._map._docLayer._annotations._items.length === 0 || !this.options.marginSet)
this.options.extraSize = 0;
- else
- this.options.extraSize = 290;
- /// as used for the size of actual comments
var classMajorSep = 'loleaflet-ruler-maj',
classMargin = 'loleaflet-ruler-margin',
@@ -153,12 +152,24 @@ L.Control.Ruler = L.Control.extend({
_fixOffset: function() {
var scale = this._map.getZoomScale(this._map.getZoom(), 10);
var mapPane = this._map._mapPane;
- var fTile = mapPane.getElementsByClassName('leaflet-tile')[0];
+
+ /// The rulerOffset depends on the leftmost tile's position
+ /// sometimes the leftmost tile is not available and we need to calculate
+ /// from the tiles that we have already.
+ var tiles = this._map._docLayer._tiles;
+ var firstTileKey = Object.keys(tiles)[0];
+ var columnNumber = parseInt(firstTileKey.match(/(\d*):/)[1]);
+ var firstTile = tiles[firstTileKey].el;
+ var firstTileXTranslate = parseInt(firstTile.style.left) - this._map._docLayer._tileWidthPx * columnNumber;
+
var tileContainer = mapPane.getElementsByClassName('leaflet-tile-container');
tileContainer = tileContainer[tileContainer.length - 1];
- var mapPaneOffset = parseInt(mapPane.style.transform.match(/\(([-0-9]*)/)[1]) + parseInt(fTile.style.left) + parseInt(tileContainer.style.transform.match(/\(([-0-9]*)/)[1]) + 18 * scale;
+ var tileContainerXTranslate = parseInt(tileContainer.style.transform.match(/\(([-0-9]*)/)[1]);
+ var mapPaneXTranslate = parseInt(mapPane.style.transform.match(/\(([-0-9]*)/)[1]);
+
+ var rulerOffset = mapPaneXTranslate + firstTileXTranslate + tileContainerXTranslate + (this.options.tileMargin * scale);
- this._rFace.style.marginLeft = mapPaneOffset + 'px';
+ this._rFace.style.marginLeft = rulerOffset + 'px';
},
_initiateDrag: function(e) {
diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index d080cdfe..0325284f 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -391,10 +391,10 @@ L.GridLayer = L.Layer.extend({
var scrollPixelLimits = new L.Point(this._docWidthTwips / this._tileWidthTwips,
this._docHeightTwips / this._tileHeightTwips);
- scrollPixelLimits = extraSize ? scrollPixelLimits.multiplyBy(this._tileSize).add(extraSize) :
+ 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});
+ this._map.fire('docsize', {x: scrollPixelLimits.x, y: scrollPixelLimits.y, extraSize: extraSize});
},
_checkSpreadSheetBounds: function (newZoom) {
More information about the Libreoffice-commits
mailing list