From ccf216d08d05536d8954153aeb7fbe6381d12709 Mon Sep 17 00:00:00 2001 From: Crisman Carmona Date: Fri, 22 Sep 2017 11:03:05 -0500 Subject: [PATCH] XOR switching between bar and spinner XOR switching between bar and spinner --- src/loading-bar.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/loading-bar.js b/src/loading-bar.js index 44e092a..765f48f 100644 --- a/src/loading-bar.js +++ b/src/loading-bar.js @@ -97,7 +97,7 @@ angular.module('cfp.loadingBarInterceptor', ['cfp.loadingBar']) $rootScope.$broadcast('cfpLoadingBar:loading', {url: config.url}); if (reqsTotal === 0) { startTimeout = $timeout(function() { - cfpLoadingBar.start(); + cfpLoadingBar.start(config.switchMethods); }, latencyThreshold); } reqsTotal++; @@ -168,6 +168,7 @@ angular.module('cfp.loadingBar', []) this.parentSelector = 'body'; this.spinnerTemplate = '
'; this.loadingBarTemplate = '
'; + this.switchMethods = false; this.$get = ['$injector', '$document', '$timeout', '$rootScope', function ($injector, $document, $timeout, $rootScope) { var $animate; @@ -185,11 +186,12 @@ angular.module('cfp.loadingBar', []) var includeSpinner = this.includeSpinner; var includeBar = this.includeBar; var startSize = this.startSize; + var switchMethods = this.switchMethods; /** * Inserts the loading bar element into the dom, and sets it to 2% */ - function _start() { + function _start(switchMethods) { if (!$animate) { $animate = $injector.get('$animate'); } @@ -217,11 +219,13 @@ angular.module('cfp.loadingBar', []) $rootScope.$broadcast('cfpLoadingBar:started'); started = true; - if (includeBar) { + //XOR with switchMethods + + if ((includeBar && !switchMethods) || (!includeBar && switchMethods)) { $animate.enter(loadingBarContainer, $parent, $after); } - if (includeSpinner) { + if ((includeSpinner && !switchMethods) || (!includeSpinner && switchMethods)) { $animate.enter(spinner, $parent, loadingBarContainer); }