[Libreoffice-commits] online.git: Branch 'feature/calc-canvas' - loleaflet/src
Jan Holesovsky (via logerrit)
logerrit at kemper.freedesktop.org
Mon Aug 31 23:49:43 UTC 2020
loleaflet/src/map/Map.js | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
New commits:
commit dfd77d44836661472908993cbedcef41996c3487
Author: Jan Holesovsky <kendy at collabora.com>
AuthorDate: Tue Sep 1 01:39:07 2020 +0200
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Tue Sep 1 01:49:04 2020 +0200
calc canvas: Fix occasional off-by-one error that results in a blurry canvas.
The core of the fix is in _getNewPixelOrigin() where the round() behaves
non-predictably / inconsistently with the rest of the code, causing
random off-by-one error that shows (or not) depending on the window
size.
The biggest problem of this is that this off-by-one is then multiplied
somewhere by the zoom factor, causing the canvas being completely
blurry; but eventually when the user clicked into the sheet, it
'magically' fixed itself.
The rest of the changes (in setZoom()) should actually do the same thing
as the previous code, but using existing methods, instead of computing
the shifts manually.
Change-Id: If0ecb1301b7c1e65cfe8126385ef959c584c5d16
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 84a286eb6..718af8b05 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -474,6 +474,8 @@ L.Map = L.Evented.extend({
this._zoom = this._limitZoom(zoom);
return this;
}
+
+ var curCenter = this.getCenter();
if (this._docLayer && this._docLayer._docType === 'spreadsheet') {
// for spreadsheets, when the document is smaller than the viewing area
// we want it to be glued to the row/column headers instead of being centered
@@ -483,14 +485,18 @@ L.Map = L.Evented.extend({
var sheetGeom = calcLayer.sheetGeometry;
var cellRange = sheetGeom.getViewCellRange();
var col = cellRange.columnrange.start, row = cellRange.rowrange.start;
- var zoomScaleAbs = Math.pow(1.2, (zoom - this.options.zoom));
+ var zoomScaleAbs = this.zoomToFactor(zoom);
+
var newTopLeftPx = sheetGeom.getCellRect(col, row, zoomScaleAbs).getTopLeft();
- var newCenterPx = newTopLeftPx.add(this.getSize().divideBy(2)._floor());
- var newCenterLatLng = this.unproject(newCenterPx, zoom);
+ var moveByPoint = this._getTopLeftPoint(curCenter, zoom).subtract(newTopLeftPx);
+
+ // move the center (which is in LatLng) by the computed amount of pixels
+ var newCenterLatLng = this.unproject(this.project(curCenter, zoom).subtract(moveByPoint), zoom);
+
return this.setView(newCenterLatLng, zoom, {zoom: options});
}
}
- var curCenter = this.getCenter();
+
if (this._docLayer && this._docLayer._visibleCursor && this.getBounds().contains(this._docLayer._visibleCursor.getCenter())) {
// Calculate new center after zoom. The intent is that the caret
// position stays the same.
@@ -1671,13 +1677,13 @@ L.Map = L.Evented.extend({
var pixelOrigin = center && zoom !== undefined ?
this._getNewPixelOrigin(center, zoom) :
this.getPixelOrigin();
+
return pixelOrigin.subtract(this._getMapPanePos());
},
_getNewPixelOrigin: function (center, zoom) {
var viewHalf = this.getSize()._divideBy(2);
- // TODO round on display, not calculation to increase precision?
- return this.project(center, zoom)._subtract(viewHalf)._add(this._getMapPanePos())._round();
+ return this.project(center, zoom)._subtract(viewHalf)._add(this._getMapPanePos())._floor();
},
_latLngToNewLayerPoint: function (latlng, zoom, center) {
More information about the Libreoffice-commits
mailing list