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

New commits:
commit a6e6f9f96d165d4053e405444461c2f8fbabdb54
Author: Marco Cecchetti <marco.cecche...@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 <pran...@collabora.co.uk>
    Tested-by: pranavk <pran...@collabora.co.uk>
    (cherry picked from commit 79d18be88ca361b14c42872d2575c571d8294dec)
    Reviewed-on: https://gerrit.libreoffice.org/31547
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>
    Tested-by: Jan Holesovsky <ke...@collabora.com>

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) {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to