loleaflet/src/layer/tile/TileLayer.js |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

New commits:
commit f5de78f920ec6f996dd4fbc386d828616733047c
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Mon Apr 16 17:17:08 2018 -0400
Commit:     Henry Castro <hcas...@collabora.com>
CommitDate: Mon Jul 23 16:05:53 2018 -0400

    loleaflet: fix when document window zooms out until it disappears
    
    Change-Id: If0f7234429130aed47dbc9156fde2e125680638f

diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 9d8cc9e8e..f7cee95bd 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -2141,20 +2141,19 @@ L.TileLayer = L.GridLayer.extend({
        },
 
        _fitWidthZoom: function (e, maxZoom) {
+               if (isNaN(this._docWidthTwips)) { return; }
                var size = e ? e.newSize : this._map.getSize();
                var widthTwips = size.x * this._map.options.tileWidthTwips / 
this._tileSize;
-               maxZoom = maxZoom ? maxZoom : this._map.getZoom();
+               var ratio = widthTwips / this._docWidthTwips;
 
+               maxZoom = maxZoom ? maxZoom : this.options.maxZoom;
                // 'fit width zoom' has no use in spreadsheets, ignore it there
                if (this._docType !== 'spreadsheet') {
                        var crsScale = this._map.options.crs.scale(1);
-                       if (this._docWidthTwips > 0)
-                       {
-                               var ratio = widthTwips / this._docWidthTwips;
-                               var zoom = this._map.getZoom() + 
Math.floor(Math.log(ratio) / Math.log(crsScale));
+                       var zoom = 10 + Math.floor(Math.log(ratio) / 
Math.log(crsScale));
 
-                               zoom = Math.max(1, zoom);
-                               zoom = Math.min(maxZoom, zoom);
+                       zoom = Math.min(maxZoom, Math.max(1, zoom));
+                       if (this._docWidthTwips * this._map.getZoomScale(zoom, 
10) < widthTwips) {
                                this._map.setZoom(zoom, {animate: false});
                        }
                }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to