@@ -26,7 +26,7 @@ angular.module('angular-loading-bar', ['chieffancypants.loadingBar']);
2626angular . 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