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

Henry Castro (via logerrit) logerrit at kemper.freedesktop.org
Tue Jul 7 15:29:06 UTC 2020


 loleaflet/src/control/Control.PartsPreview.js |    9 ++++++---
 loleaflet/src/control/Parts.js                |    7 +++++--
 2 files changed, 11 insertions(+), 5 deletions(-)

New commits:
commit f68d5346a9bc535d82c45b39876dc8f8b3824694
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Fri Jul 3 15:59:32 2020 -0400
Commit:     Henry Castro <hcastro at collabora.com>
CommitDate: Tue Jul 7 17:28:47 2020 +0200

    loleaflet: fix the bounding rectangle when not visible
    
    The preview thumbnail in mobile wizard are not visible yet,
    so assume the map container rectangle bounds to properly
    calculate the aspect ratio of the image
    
    Change-Id: Iacc387b92e326965c86fb60d1acfde5b49365ad3
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97899
    Tested-by: Jenkins
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Henry Castro <hcastro at collabora.com>

diff --git a/loleaflet/src/control/Control.PartsPreview.js b/loleaflet/src/control/Control.PartsPreview.js
index 7500bbbb4..5e62fc832 100644
--- a/loleaflet/src/control/Control.PartsPreview.js
+++ b/loleaflet/src/control/Control.PartsPreview.js
@@ -220,6 +220,11 @@ L.Control.PartsPreview = L.Control.extend({
 		var previewContBB = this._partsPreviewCont.getBoundingClientRect();
 		var bottomBound;
 
+		// is not visible yet, assume map bounds
+		if (previewContBB.right === 0 && previewContBB.bottom === 0) {
+			previewContBB = this._map._container.getBoundingClientRect();
+		}
+
 		if (this._direction === 'x') {
 			this._previewContTop = previewContBB.left;
 			bottomBound = previewContBB.right + previewContBB.width / 2;
@@ -258,9 +263,7 @@ L.Control.PartsPreview = L.Control.extend({
 		var imgSize;
 		if (i === 0 || (previewFrameTop >= topBound && previewFrameTop <= bottomBound)
 			|| (previewFrameBottom >= topBound && previewFrameBottom <= bottomBound)) {
-			imgSize = this.options.fetchThumbnail ?
-				this._map.getPreview(i, i, this.options.maxWidth, this.options.maxHeight, {autoUpdate: this.options.autoUpdate}) :
-				{ width: this.options.maxWidth, height: this.options.maxHeight };
+			imgSize = this._map.getPreview(i, i, this.options.maxWidth, this.options.maxHeight, {autoUpdate: this.options.autoUpdate, fetchThumbnail: this.options.fetchThumbnail});
 			img.fetched = true;
 
 			if (this._direction === 'x') {
diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index 72a213402..de3bcdd9f 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -103,6 +103,7 @@ L.Map.include({
 		}
 		var autoUpdate = options ? !!options.autoUpdate : false;
 		var forAllClients = options ? !!options.broadcast : false;
+		var fetchThumbnail = options && options.fetchThumbnail ? options.fetchThumbnail : true;
 		this._docPreviews[id] = {id: id, index: index, maxWidth: maxWidth, maxHeight: maxHeight, autoUpdate: autoUpdate, invalid: false};
 
 		var docLayer = this._docLayer;
@@ -131,7 +132,8 @@ L.Map.include({
 			dpiscale = 2; // some may be hidpi, and it is fine to send the hi-dpi slide preview to non-hpi clients
 		}
 
-		this._socket.sendMessage('tile ' +
+		if (fetchThumbnail) {
+			this._socket.sendMessage('tile ' +
 							'nviewid=0' + ' ' +
 							'part=' + part + ' ' +
 							'width=' + maxWidth * dpiscale + ' ' +
@@ -141,7 +143,8 @@ L.Map.include({
 							'tilewidth=' + tileWidth + ' ' +
 							'tileheight=' + tileHeight + ' ' +
 							'id=' + id + ' ' +
-							'broadcast=' + (forAllClients ? 'yes' : 'no'));
+						 'broadcast=' + (forAllClients ? 'yes' : 'no'));
+		}
 
 		return {width: maxWidth, height: maxHeight};
 	},


More information about the Libreoffice-commits mailing list