[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-cd-3-2' - loleaflet/src

Marco Cecchetti marco.cecchetti at collabora.com
Thu Jun 28 15:26:19 UTC 2018


 loleaflet/src/control/Control.PartsPreview.js |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

New commits:
commit 1990c9d15a19f29466294c17c98dba00a89118dc
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Sun Jun 24 22:05:29 2018 +0200

    On-demand loading of previews in the Online Draw/Impress - follow up
    
    setting extra bounds for fetching some further previews even if not
    visible.
    
    Change-Id: I83b403cbb131e898a5064e017502edd7251bd242
    Reviewed-on: https://gerrit.libreoffice.org/56407
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/control/Control.PartsPreview.js b/loleaflet/src/control/Control.PartsPreview.js
index 2b0a70f1b..cd549b32c 100644
--- a/loleaflet/src/control/Control.PartsPreview.js
+++ b/loleaflet/src/control/Control.PartsPreview.js
@@ -89,6 +89,7 @@ L.Control.PartsPreview = L.Control.extend({
 			previewFrameTop = this._previewContTop + this._previewFrameMargin + i * (this._previewFrameHeight + this._previewFrameMargin);
 			previewFrameTop -= this._scrollY;
 			previewFrameBottom = previewFrameTop + this._previewFrameHeight;
+			L.DomUtil.setStyle(img, 'height', this._previewImgHeight + 'px');
 		}
 
 		var imgSize;
@@ -96,6 +97,7 @@ L.Control.PartsPreview = L.Control.extend({
 			|| (previewFrameBottom >= topBound && previewFrameBottom <= bottomBound)) {
 			imgSize = this._map.getPreview(i, i, 180, 180, {autoUpdate: this.options.autoUpdate});
 			img.fetched = true;
+			L.DomUtil.setStyle(img, 'height', '');
 		}
 
 		if (i === 0) {
@@ -106,6 +108,7 @@ L.Control.PartsPreview = L.Control.extend({
 				imgHeight = Math.round(imgHeight * previewImgMinWidth / imgSize.width);
 			var previewFrameBB = frame.getBoundingClientRect();
 			this._previewFrameMargin = previewFrameBB.top - this._previewContTop;
+			this._previewImgHeight = imgHeight;
 			this._previewFrameHeight = imgHeight + 2 * previewImgBorder;
 		}
 
@@ -235,11 +238,17 @@ L.Control.PartsPreview = L.Control.extend({
 	},
 
 	_onScroll: function (e) {
-		this._scrollY = -e.mcs.top;
+		var scrollOffset = 0;
+		if (e) {
+			var prevScrollY = this._scrollY;
+			this._scrollY = -e.mcs.top;
+			scrollOffset = this._scrollY - prevScrollY;
+		}
 
 		var previewContBB = this._partsPreviewCont.getBoundingClientRect();
-		var topBound = this._previewContTop - previewContBB.height / 2;
-		var bottomBound = topBound + previewContBB.height + previewContBB.height / 2;
+		var extra =  previewContBB.height;
+		var topBound = this._previewContTop - (scrollOffset < 0 ? extra : previewContBB.height / 2);
+		var bottomBound = this._previewContTop + previewContBB.height + (scrollOffset > 0 ? extra : previewContBB.height / 2);
 		for (var i = 0; i < this._previewTiles.length; ++i) {
 			var img = this._previewTiles[i];
 			if (img && img.parentNode && !img.fetched) {


More information about the Libreoffice-commits mailing list