loleafet: simplify to compute the bottom bound of the preview thumbnails

Change-Id: I5ee8c5b4182b2752821fcd3bba022bc4b3db42d1
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97778
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Henry Castro <hcastro@collabora.com>
This commit is contained in:
Henry Castro 2020-07-02 15:13:12 -04:00
parent 67bd664901
commit 0e3f2d7c9f

View file

@ -86,18 +86,9 @@ L.Control.PartsPreview = L.Control.extend({
$('.scroll-container').mCustomScrollbar('update');
}, this), 500);
}
var previewContBB = this._partsPreviewCont.getBoundingClientRect();
var bottomBound;
this.createScrollbar();
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;
}
var bottomBound = this._getBottomBound();
this._map.on('click', function() {
this.partsFocused = false;
@ -180,17 +171,7 @@ L.Control.PartsPreview = L.Control.extend({
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;
}
var bottomBound = this._getBottomBound();
for (var prev = 0; prev < this._previewTiles.length; prev++) {
this._layoutPreview(prev, this._previewTiles[prev], bottomBound);
}
@ -230,6 +211,21 @@ L.Control.PartsPreview = L.Control.extend({
return img;
},
_getBottomBound: function () {
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;
}
return bottomBound;
},
_layoutPreview: function (i, img, bottomBound) {
var topBound = this._previewContTop;
var previewFrameTop = 0;