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

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Wed Jul 29 15:35:16 UTC 2020


 loleaflet/src/layer/marker/ProgressOverlay.js |   58 +++++++++-----------------
 1 file changed, 22 insertions(+), 36 deletions(-)

New commits:
commit 487be77dc433be99ae28937f9e55973185106a21
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Jul 29 16:48:39 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Jul 29 17:34:57 2020 +0200

    More cleanup in the progressbar code
    
    Change-Id: I8bb27f9ef989e01ecf29d4ee7b9753ed10fb0483
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/99708
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/loleaflet/src/layer/marker/ProgressOverlay.js b/loleaflet/src/layer/marker/ProgressOverlay.js
index fe6286279..82306cbda 100644
--- a/loleaflet/src/layer/marker/ProgressOverlay.js
+++ b/loleaflet/src/layer/marker/ProgressOverlay.js
@@ -17,21 +17,6 @@ L.ProgressOverlay = L.Layer.extend({
 		this.intervalTimer = undefined;
 	},
 
-	onAdd: function () {
-		this._spinnerInterval = L.LOUtil.startSpinner(this._spinnerCanvas, this.options.spinnerSpeed);
-	},
-
-	onRemove: function () {
-		if (this._container) {
-			L.DomUtil.get('document-container').removeChild(this._container);
-			this._container = null;
-		}
-
-		if (this._spinnerInterval) {
-			clearInterval(this._spinnerInterval);
-		}
-	},
-
 	_initLayout: function () {
 		this._container = L.DomUtil.create('div', 'leaflet-progress-layer', L.DomUtil.get('document-container'));
 		this._spinner = L.DomUtil.create('div', 'leaflet-progress-spinner', this._container);
@@ -60,6 +45,10 @@ L.ProgressOverlay = L.Layer.extend({
 		if (this.intervalTimer)
 			clearInterval(this.intervalTimer);
 		this.intervalTimer = undefined;
+
+		if (this._spinnerInterval)
+			clearInterval(this._spinnerInterval);
+		this._spinnerInterval = undefined;
 	},
 
 	// Show the progress bar, but only if things seem slow
@@ -78,8 +67,7 @@ L.ProgressOverlay = L.Layer.extend({
 				switch (self.state) {
 				// 0.5s -> start the spinner
 				case 1:
-					if (!map.hasLayer(self))
-						map.addLayer(self);
+					self._spinnerInterval = L.LOUtil.startSpinner(self._spinnerCanvas, self.options.spinnerSpeed);
 					break;
 				// 2s -> enable the progress bar if we have one & it's low
 				case 4:
@@ -91,43 +79,41 @@ L.ProgressOverlay = L.Layer.extend({
 					self.setBar(bar);
 					break;
 				}
-				if (!map.hasLayer(self)) {
-					map.addLayer(self);
-				}
 			}, 500 /* ms */);
 	},
 
 	// Hide ourselves if there is anything to hide
-	end: function(map) {
+	end: function() {
 		this.shutdownTimer();
-		if (map.hasLayer(this)) {
-			map.removeLayer(this);
-		}
-		if (this._container) {
+
+		if (this._container)
 			L.DomUtil.get('document-container').removeChild(this._container);
-			this._container = null;
-		}
+		this._container = undefined;
 	},
 
 	setLabel: function (label) {
-		if (this._label.innerHTML !== label) {
+		if (this._container && this._label.innerHTML !== label) {
 			this._label.innerHTML = label;
 		}
 	},
 
 	setBar: function (bar) {
-		if (bar) {
-			this._progress.style.visibility = '';
-		}
-		else {
-			this._progress.style.visibility = 'hidden';
+		if (this._container) {
+			if (bar) {
+				this._progress.style.visibility = '';
+			}
+			else {
+				this._progress.style.visibility = 'hidden';
+			}
 		}
 	},
 
 	setValue: function (value) {
-		this._percent = value;
-		this._bar.style.width = value + '%';
-		this._value.innerHTML = value + '%';
+		if (this._container) {
+			this._percent = value;
+			this._bar.style.width = value + '%';
+			this._value.innerHTML = value + '%';
+		}
 	}
 });
 


More information about the Libreoffice-commits mailing list