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

New commits:
commit 40e39b00abc24a7fb642b5b496120910fbb356a8
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Wed Jul 29 20:57:18 2020 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Fri Jul 31 09:07:42 2020 +0200

    Add progressbar on demand
    
    This fixes bug in Android app where progressbar
    was added without any condition.
    
    Change-Id: I535001fce4ae37da4f5dc87031d9c15db043d655
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/99731
    Tested-by: Jenkins
    Tested-by: Szymon Kłos <szymon.k...@collabora.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>

diff --git a/loleaflet/src/layer/marker/ProgressOverlay.js 
b/loleaflet/src/layer/marker/ProgressOverlay.js
index 222d376f7..ea8da83f7 100644
--- a/loleaflet/src/layer/marker/ProgressOverlay.js
+++ b/loleaflet/src/layer/marker/ProgressOverlay.js
@@ -3,7 +3,7 @@
  * L.ProgressOverlay is used to overlay progress images over the map.
  */
 
- /* global brandProductName */
+ /* global brandProductName $ */
 L.ProgressOverlay = L.Layer.extend({
 
        options: {
@@ -17,8 +17,9 @@ L.ProgressOverlay = L.Layer.extend({
                this.intervalTimer = undefined;
        },
 
+       // create layout but don't add to the DOM yet
        _initLayout: function () {
-               this._container = L.DomUtil.create('div', 
'leaflet-progress-layer', L.DomUtil.get('document-container'));
+               this._container = L.DomUtil.create('div', 
'leaflet-progress-layer');
                this._spinner = L.DomUtil.create('div', 
'leaflet-progress-spinner', this._container);
                this._spinnerCanvas = L.DomUtil.create('canvas', 
'leaflet-progress-spinner-canvas', this._spinner);
 
@@ -51,6 +52,16 @@ L.ProgressOverlay = L.Layer.extend({
                this._spinnerInterval = undefined;
        },
 
+       showSpinner: function() {
+               
L.DomUtil.get('document-container').appendChild(this._container);
+               this._spinnerInterval = 
L.LOUtil.startSpinner(this._spinnerCanvas, this.options.spinnerSpeed);
+       },
+
+       hideSpinner: function() {
+               if (this._container)
+                       $(this._container).remove();
+       },
+
        // Show the progress bar, but only if things seem slow
        delayedStart: function(map, label, bar) {
                this.setLabel(label);
@@ -67,7 +78,7 @@ L.ProgressOverlay = L.Layer.extend({
                                switch (self.state) {
                                // 0.5s -> start the spinner
                                case 1:
-                                       self._spinnerInterval = 
L.LOUtil.startSpinner(self._spinnerCanvas, self.options.spinnerSpeed);
+                                       self.showSpinner();
                                        break;
                                // 2s -> enable the progress bar if we have one 
& it's low
                                case 4:
@@ -85,10 +96,7 @@ L.ProgressOverlay = L.Layer.extend({
        // Hide ourselves if there is anything to hide
        end: function() {
                this.shutdownTimer();
-
-               if (this._container)
-                       
L.DomUtil.get('document-container').removeChild(this._container);
-               this._container = undefined;
+               this.hideSpinner();
        },
 
        setLabel: function (label) {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to