Skip to content

Commit 3b2b934

Browse files
remove duplicate events, and change start event to honor latencyThreshold
1 parent 5bfa29a commit 3b2b934

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

build/loading-bar.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ angular.module('cfp.loadingBarInterceptor', ['cfp.loadingBar'])
100100
// Check to make sure this request hasn't already been cached and that
101101
// the requester didn't explicitly ask us to ignore this request:
102102
if (!config.ignoreLoadingBar && !isCached(config)) {
103-
$rootScope.$broadcast('cfpLoadingBar:loading', {url: config.url});
104103
if (reqsTotal === 0) {
105104
startTimeout = $timeout(function() {
105+
$rootScope.$broadcast('cfpLoadingBar:loading', {url: config.url});
106106
cfpLoadingBar.start();
107107
}, latencyThreshold);
108108
}
@@ -120,8 +120,8 @@ angular.module('cfp.loadingBarInterceptor', ['cfp.loadingBar'])
120120

121121
if (!response.config.ignoreLoadingBar && !isCached(response.config)) {
122122
reqsCompleted++;
123-
$rootScope.$broadcast('cfpLoadingBar:loaded', {url: response.config.url, result: response});
124123
if (reqsCompleted >= reqsTotal) {
124+
$rootScope.$broadcast('cfpLoadingBar:loaded', {url: response.config.url, result: response});
125125
setComplete();
126126
} else {
127127
cfpLoadingBar.set(reqsCompleted / reqsTotal);
@@ -138,8 +138,8 @@ angular.module('cfp.loadingBarInterceptor', ['cfp.loadingBar'])
138138

139139
if (!rejection.config.ignoreLoadingBar && !isCached(rejection.config)) {
140140
reqsCompleted++;
141-
$rootScope.$broadcast('cfpLoadingBar:loaded', {url: rejection.config.url, result: rejection});
142141
if (reqsCompleted >= reqsTotal) {
142+
$rootScope.$broadcast('cfpLoadingBar:loaded', {url: rejection.config.url, result: rejection});
143143
setComplete();
144144
} else {
145145
cfpLoadingBar.set(reqsCompleted / reqsTotal);

build/loading-bar.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/loading-bar.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ angular.module('cfp.loadingBarInterceptor', ['cfp.loadingBar'])
9494
// Check to make sure this request hasn't already been cached and that
9595
// the requester didn't explicitly ask us to ignore this request:
9696
if (!config.ignoreLoadingBar && !isCached(config)) {
97-
$rootScope.$broadcast('cfpLoadingBar:loading', {url: config.url});
9897
if (reqsTotal === 0) {
9998
startTimeout = $timeout(function() {
99+
$rootScope.$broadcast('cfpLoadingBar:loading', {url: config.url});
100100
cfpLoadingBar.start();
101101
}, latencyThreshold);
102102
}
@@ -114,8 +114,8 @@ angular.module('cfp.loadingBarInterceptor', ['cfp.loadingBar'])
114114

115115
if (!response.config.ignoreLoadingBar && !isCached(response.config)) {
116116
reqsCompleted++;
117-
$rootScope.$broadcast('cfpLoadingBar:loaded', {url: response.config.url, result: response});
118117
if (reqsCompleted >= reqsTotal) {
118+
$rootScope.$broadcast('cfpLoadingBar:loaded', {url: response.config.url, result: response});
119119
setComplete();
120120
} else {
121121
cfpLoadingBar.set(reqsCompleted / reqsTotal);
@@ -132,8 +132,8 @@ angular.module('cfp.loadingBarInterceptor', ['cfp.loadingBar'])
132132

133133
if (!rejection.config.ignoreLoadingBar && !isCached(rejection.config)) {
134134
reqsCompleted++;
135-
$rootScope.$broadcast('cfpLoadingBar:loaded', {url: rejection.config.url, result: rejection});
136135
if (reqsCompleted >= reqsTotal) {
136+
$rootScope.$broadcast('cfpLoadingBar:loaded', {url: rejection.config.url, result: rejection});
137137
setComplete();
138138
} else {
139139
cfpLoadingBar.set(reqsCompleted / reqsTotal);

0 commit comments

Comments
 (0)