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

Henry Castro (via logerrit) logerrit at kemper.freedesktop.org
Sat Nov 16 18:29:06 UTC 2019


 loleaflet/src/control/Control.PartsPreview.js |   46 +++++++++++++-------------
 1 file changed, 24 insertions(+), 22 deletions(-)

New commits:
commit acb4f87bd48b71386afeb4b92ba5f8e827415411
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Sat Nov 16 13:01:58 2019 -0400
Commit:     Henry Castro <hcastro at collabora.com>
CommitDate: Sat Nov 16 19:28:44 2019 +0100

    loleaflet: defer request preview thumbnail task
    
    When mCustomScrollbar fires onScroll then queue the task to run as soon
    as the current synchronizing code.
    
    Change-Id: I761937a0ad181a42b592ad953cc7b83ea73a1b21
    Reviewed-on: https://gerrit.libreoffice.org/82990
    Reviewed-by: Henry Castro <hcastro at collabora.com>
    Tested-by: Henry Castro <hcastro at collabora.com>

diff --git a/loleaflet/src/control/Control.PartsPreview.js b/loleaflet/src/control/Control.PartsPreview.js
index 1dfa77f84..9a52aeb10 100644
--- a/loleaflet/src/control/Control.PartsPreview.js
+++ b/loleaflet/src/control/Control.PartsPreview.js
@@ -393,34 +393,36 @@ L.Control.PartsPreview = L.Control.extend({
 	},
 
 	_onScroll: function (e) {
-		var scrollOffset = 0;
-		if (e) {
-			var prevScrollY = this._scrollY;
-			this._scrollY = this._direction === 'x' ? -e.mcs.left : -e.mcs.top;
-			scrollOffset = this._scrollY - prevScrollY;
-		}
+		setTimeout(L.bind(function (e) {
+			var scrollOffset = 0;
+			if (e) {
+				var prevScrollY = this._scrollY;
+				this._scrollY = this._direction === 'x' ? -e.mcs.left : -e.mcs.top;
+				scrollOffset = this._scrollY - prevScrollY;
+			}
 
-		var previewContBB = this._partsPreviewCont.getBoundingClientRect();
-		var extra =  this._direction === 'x' ? previewContBB.width : previewContBB.height;
-		var topBound = this._previewContTop - (scrollOffset < 0 ? extra : extra / 2);
-		var bottomBound = this._previewContTop + extra + (scrollOffset > 0 ? extra : extra / 2);
-		for (var i = 0; i < this._previewTiles.length; ++i) {
-			var img = this._previewTiles[i];
-			if (img && img.parentNode && !img.fetched) {
-				var previewFrameBB = img.parentNode.getBoundingClientRect();
-				if (this._direction === 'x') {
-					if ((previewFrameBB.left >= topBound && previewFrameBB.left <= bottomBound)
-					|| (previewFrameBB.right >= topBound && previewFrameBB.right <= bottomBound)) {
+			var previewContBB = this._partsPreviewCont.getBoundingClientRect();
+			var extra =  this._direction === 'x' ? previewContBB.width : previewContBB.height;
+			var topBound = this._previewContTop - (scrollOffset < 0 ? extra : extra / 2);
+			var bottomBound = this._previewContTop + extra + (scrollOffset > 0 ? extra : extra / 2);
+			for (var i = 0; i < this._previewTiles.length; ++i) {
+				var img = this._previewTiles[i];
+				if (img && img.parentNode && !img.fetched) {
+					var previewFrameBB = img.parentNode.getBoundingClientRect();
+					if (this._direction === 'x') {
+						if ((previewFrameBB.left >= topBound && previewFrameBB.left <= bottomBound)
+						|| (previewFrameBB.right >= topBound && previewFrameBB.right <= bottomBound)) {
+							this._map.getPreview(i, i, this.options.maxWidth, this.options.maxHeight, {autoUpdate: this.options.autoUpdate});
+							img.fetched = true;
+						}
+					} else if ((previewFrameBB.top >= topBound && previewFrameBB.top <= bottomBound)
+						|| (previewFrameBB.bottom >= topBound && previewFrameBB.bottom <= bottomBound)) {
 						this._map.getPreview(i, i, this.options.maxWidth, this.options.maxHeight, {autoUpdate: this.options.autoUpdate});
 						img.fetched = true;
 					}
-				} else if ((previewFrameBB.top >= topBound && previewFrameBB.top <= bottomBound)
-					|| (previewFrameBB.bottom >= topBound && previewFrameBB.bottom <= bottomBound)) {
-					this._map.getPreview(i, i, this.options.maxWidth, this.options.maxHeight, {autoUpdate: this.options.autoUpdate});
-					img.fetched = true;
 				}
 			}
-		}
+		}, this, e), 0);
 	},
 
 	_addDnDHandlers: function (elem) {


More information about the Libreoffice-commits mailing list