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

New commits:
commit 568bc0d785fdcc9ef1585d9990c0c89cf841e2a8
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Wed Jul 29 16:48:39 2020 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Wed Jul 29 21:43:13 2020 +0200

    More cleanup in the progressbar code
    
    Change-Id: I8bb27f9ef989e01ecf29d4ee7b9753ed10fb0483
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/99708
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>
    (cherry picked from commit 487be77dc433be99ae28937f9e55973185106a21)
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/99609
    Tested-by: Jenkins

diff --git a/loleaflet/src/layer/marker/ProgressOverlay.js 
b/loleaflet/src/layer/marker/ProgressOverlay.js
index 4d609b869..222d376f7 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 + '%';
+               }
        }
 });
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to