[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2' - loleaflet/src
Henry Castro (via logerrit)
logerrit at kemper.freedesktop.org
Tue Aug 11 19:45:01 UTC 2020
loleaflet/src/control/Control.PartsPreview.js | 32 +++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
New commits:
commit dcbea7d8ede6bed202fb48ce4a449dc6ef9209fc
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Thu Jul 2 10:59:56 2020 -0400
Commit: Henry Castro <hcastro at collabora.com>
CommitDate: Tue Aug 11 21:44:42 2020 +0200
loleaflet: update preview images when the doc size changes
The unit test checks the aspect ratio of the preview thumbnails,
this happens when the document size changes (i.e changing paper format)
Change-Id: I0267e797327b73d714947258e004fe64cce9d1dd
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97775
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Henry Castro <hcastro at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100548
diff --git a/loleaflet/src/control/Control.PartsPreview.js b/loleaflet/src/control/Control.PartsPreview.js
index f7f11e348..84b8a1579 100644
--- a/loleaflet/src/control/Control.PartsPreview.js
+++ b/loleaflet/src/control/Control.PartsPreview.js
@@ -39,6 +39,7 @@ L.Control.PartsPreview = L.Control.extend({
map.on('tilepreview', this._updatePreview, this);
map.on('insertpage', this._insertPreview, this);
map.on('deletepage', this._deletePreview, this);
+ map.on('docsize', this._updateAllPreview, this);
},
createScrollbar: function (axis) {
@@ -176,6 +177,27 @@ L.Control.PartsPreview = L.Control.extend({
}
},
+ _updateAllPreview: function () {
+ if (this._previewTiles.length === 0) {
+ return;
+ }
+
+ var previewContBB = this._partsPreviewCont.getBoundingClientRect();
+ var bottomBound;
+
+ if (this._direction === 'x') {
+ this._previewContTop = previewContBB.left;
+ bottomBound = previewContBB.right + previewContBB.width / 2;
+ } else {
+ this._previewContTop = previewContBB.top;
+ bottomBound = previewContBB.bottom + previewContBB.height / 2;
+ }
+
+ for (var prev = 0; prev < this._previewTiles.length; prev++) {
+ this._layoutPreview(prev, this._previewTiles[prev], bottomBound);
+ }
+ },
+
_createPreview: function (i, hashCode, bottomBound) {
var frame = L.DomUtil.create('div', 'preview-frame', this._scrollContainer);
this._addDnDHandlers(frame);
@@ -215,6 +237,12 @@ L.Control.PartsPreview = L.Control.extend({
}
}, this);
+ this._layoutPreview(i, img, bottomBound);
+
+ return img;
+ },
+
+ _layoutPreview: function (i, img, bottomBound) {
var topBound = this._previewContTop;
var previewFrameTop = 0;
var previewFrameBottom = 0;
@@ -260,7 +288,7 @@ L.Control.PartsPreview = L.Control.extend({
var imgWidth = imgSize.width;
if (imgSize.width < previewImgMinWidth)
imgHeight = Math.round(imgHeight * previewImgMinWidth / imgSize.width);
- var previewFrameBB = frame.getBoundingClientRect();
+ var previewFrameBB = img.parentElement.getBoundingClientRect();
if (this._direction === 'x') {
this._previewFrameMargin = previewFrameBB.left - this._previewContTop;
this._previewImgHeight = imgWidth;
@@ -271,8 +299,6 @@ L.Control.PartsPreview = L.Control.extend({
this._previewFrameHeight = imgHeight + 2 * previewImgBorder;
}
}
-
- return img;
},
_setPart: function (e) {
More information about the Libreoffice-commits
mailing list