loleaflet/src/core/Util.js | 9 +++++++++ loleaflet/src/map/Map.js | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-)
New commits: commit bbff6b0045e05507e73d8d3566fa0ff95e04a0cb Author: Marco Cecchetti <[email protected]> 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/35348 Reviewed-by: Thorsten Behrens <[email protected]> Tested-by: Thorsten Behrens <[email protected]> diff --git a/loleaflet/src/core/Util.js b/loleaflet/src/core/Util.js index 3637688a..5cb3ade1 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 28455165..7ef14af7 100644 --- a/loleaflet/src/map/Map.js +++ b/loleaflet/src/map/Map.js @@ -507,7 +507,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 @@ -1054,6 +1055,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 [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
