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

Marco Cecchetti marco.cecchetti at collabora.com
Fri Dec 2 12:08:24 UTC 2016


 loleaflet/src/core/Util.js |    9 +++++++++
 loleaflet/src/map/Map.js   |    8 +++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

New commits:
commit 79d18be88ca361b14c42872d2575c571d8294dec
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Wed Nov 30 23:04:48 2016 +0100

    loleaflet - calc: fixed one pixel horizontal auto-scrolling issue
    
    This patch fixes two problems for spreadsheets:
    
    - one pixel alignment offset btw grid and column header
    
    - a one pixel horizontal auto-scrolling issue
    
    Change-Id: Ifd6a3b47863d345656d0dcf3fba2d253c43ba9b1
    Reviewed-on: https://gerrit.libreoffice.org/31542
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>

diff --git a/loleaflet/src/core/Util.js b/loleaflet/src/core/Util.js
index 3637688..5cb3ade 100644
--- a/loleaflet/src/core/Util.js
+++ b/loleaflet/src/core/Util.js
@@ -126,6 +126,14 @@ L.Util = {
 		return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&');
 	},
 
+	round: function(x, e) {
+		if (!e) {
+			return Math.round(x);
+		}
+		var f = 1.0/e;
+		return Math.round(x * f) * e;
+	},
+
 	// super-simple templating facility, used for TileLayer URLs
 	template: function (str, data) {
 		return str.replace(L.Util.templateRe, function (str, key) {
@@ -194,3 +202,4 @@ L.extend = L.Util.extend;
 L.bind = L.Util.bind;
 L.stamp = L.Util.stamp;
 L.setOptions = L.Util.setOptions;
+L.round = L.Util.round;
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 317bf7c..c3f2697 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -509,7 +509,8 @@ L.Map = L.Evented.extend({
 
 	project: function (latlng, zoom) { // (LatLng[, Number]) -> Point
 		zoom = zoom === undefined ? this._zoom : zoom;
-		return this.options.crs.latLngToPoint(L.latLng(latlng), zoom);
+		var projectedPoint = this.options.crs.latLngToPoint(L.latLng(latlng), zoom);
+		return new L.Point(L.round(projectedPoint.x, 1e-6), L.round(projectedPoint.y, 1e-6));
 	},
 
 	unproject: function (point, zoom) { // (Point[, Number]) -> LatLng
@@ -1057,6 +1058,11 @@ L.Map = L.Evented.extend({
 		return left + right > 0 ?
 			Math.round(left - right) / 2 :
 			Math.max(0, Math.ceil(left)) - Math.max(0, Math.floor(right));
+		// TODO: do we really need ceil and floor ?
+		// for spreadsheets it can cause one pixel alignment offset btw grid and row/column header
+		// and a one pixel horizontal auto-scrolling issue;
+		// both issues have been fixed by rounding the projection: see Map.project above;
+		// anyway in case of similar problems, this code needs to be checked
 	},
 
 	_limitZoom: function (zoom) {


More information about the Libreoffice-commits mailing list