Skip to content

Commit 87aae00

Browse files
issue chieffancypants#27: working but not configurable
1 parent 36db941 commit 87aae00

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/loading-bar.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ angular.module('angular-loading-bar', ['chieffancypants.loadingBar']);
2626
angular.module('chieffancypants.loadingBar', [])
2727
.config(['$httpProvider', function ($httpProvider) {
2828

29-
var interceptor = ['$q', '$cacheFactory', 'cfpLoadingBar', function ($q, $cacheFactory, cfpLoadingBar) {
29+
var interceptor = ['$q', '$cacheFactory', '$timeout', 'cfpLoadingBar', function ($q, $cacheFactory, $timeout, cfpLoadingBar) {
3030

3131
/**
3232
* The total number of requests made
@@ -44,6 +44,7 @@ angular.module('chieffancypants.loadingBar', [])
4444
* loading bar from the DOM.
4545
*/
4646
function setComplete() {
47+
$timeout.cancel(startTimeout);
4748
cfpLoadingBar.complete();
4849
reqsCompleted = 0;
4950
reqsTotal = 0;
@@ -81,13 +82,17 @@ angular.module('chieffancypants.loadingBar', [])
8182
return cached;
8283
}
8384

85+
var startTimeout;
86+
8487
return {
8588
'request': function(config) {
8689
// Check to make sure this request hasn't already been cached and that
8790
// the requester didn't explicitly ask us to ignore this request:
8891
if (!config.ignoreLoadingBar && !isCached(config)) {
8992
if (reqsTotal === 0) {
90-
cfpLoadingBar.start();
93+
startTimeout = $timeout(function() {
94+
cfpLoadingBar.start();
95+
}, 100);
9196
}
9297
reqsTotal++;
9398
}
@@ -176,6 +181,7 @@ angular.module('chieffancypants.loadingBar', [])
176181
if (includeSpinner) {
177182
$animate.enter(spinner, $parent);
178183
}
184+
179185
_set(0.02);
180186
}
181187

0 commit comments

Comments
 (0)