Skip to content

Commit c97fec2

Browse files
bump version
1 parent f1d5a62 commit c97fec2

File tree

6 files changed

+42
-25
lines changed

6 files changed

+42
-25
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-loading-bar",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"main": ["src/loading-bar.js", "src/loading-bar.css"],
55
"ignore": [
66
"**/.*",

build/loading-bar.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
2-
* angular-loading-bar v0.2.0
2+
* angular-loading-bar v0.3.0
33
* https://chieffancypants.github.io/angular-loading-bar
4-
* Copyright (c) 2013 Wes Cruver
4+
* Copyright (c) 2014 Wes Cruver
55
* License: MIT
66
*/
77

@@ -10,10 +10,10 @@
1010
#loading-bar-spinner {
1111
pointer-events: none;
1212
-webkit-pointer-events: none;
13-
-webkit-transition: 0.5s linear all;
14-
-moz-transition: 0.5s linear all;
15-
-o-transition: 0.5s linear all;
16-
transition: 0.5s linear all;
13+
-webkit-transition: 350ms linear all;
14+
-moz-transition: 350ms linear all;
15+
-o-transition: 350ms linear all;
16+
transition: 350ms linear all;
1717
}
1818

1919
#loading-bar.ng-enter,

build/loading-bar.js

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
2-
* angular-loading-bar v0.2.0
2+
* angular-loading-bar v0.3.0
33
* https://chieffancypants.github.io/angular-loading-bar
4-
* Copyright (c) 2013 Wes Cruver
4+
* Copyright (c) 2014 Wes Cruver
55
* License: MIT
66
*/
77
/*
@@ -32,7 +32,7 @@ angular.module('angular-loading-bar', ['chieffancypants.loadingBar']);
3232
angular.module('chieffancypants.loadingBar', [])
3333
.config(['$httpProvider', function ($httpProvider) {
3434

35-
var interceptor = ['$q', '$cacheFactory', '$rootScope', 'cfpLoadingBar', function ($q, $cacheFactory, $rootScope, cfpLoadingBar) {
35+
var interceptor = ['$q', '$cacheFactory', '$timeout', '$rootScope', 'cfpLoadingBar', function ($q, $cacheFactory, $timeout, $rootScope, cfpLoadingBar) {
3636

3737
/**
3838
* The total number of requests made
@@ -44,12 +44,23 @@ angular.module('chieffancypants.loadingBar', [])
4444
*/
4545
var reqsCompleted = 0;
4646

47+
/**
48+
* The amount of time spent fetching before showing the loading bar
49+
*/
50+
var latencyThreshold = cfpLoadingBar.latencyThreshold;
51+
52+
/**
53+
* $timeout handle for latencyThreshold
54+
*/
55+
var startTimeout;
56+
4757

4858
/**
4959
* calls cfpLoadingBar.complete() which removes the
5060
* loading bar from the DOM.
5161
*/
5262
function setComplete() {
63+
$timeout.cancel(startTimeout);
5364
cfpLoadingBar.complete();
5465
reqsCompleted = 0;
5566
reqsTotal = 0;
@@ -87,14 +98,17 @@ angular.module('chieffancypants.loadingBar', [])
8798
return cached;
8899
}
89100

101+
90102
return {
91103
'request': function(config) {
92104
// Check to make sure this request hasn't already been cached and that
93105
// the requester didn't explicitly ask us to ignore this request:
94106
if (!config.ignoreLoadingBar && !isCached(config)) {
95107
$rootScope.$broadcast('cfpLoadingBar:loading', {url: config.url});
96108
if (reqsTotal === 0) {
97-
cfpLoadingBar.start();
109+
startTimeout = $timeout(function() {
110+
cfpLoadingBar.start();
111+
}, latencyThreshold);
98112
}
99113
reqsTotal++;
100114
cfpLoadingBar.set(reqsCompleted / reqsTotal);
@@ -147,6 +161,7 @@ angular.module('chieffancypants.loadingBar', [])
147161

148162
this.includeSpinner = true;
149163
this.includeBar = true;
164+
this.latencyThreshold = 100;
150165
this.parentSelector = 'body';
151166

152167
this.$get = ['$document', '$timeout', '$animate', '$rootScope', function ($document, $timeout, $animate, $rootScope) {
@@ -186,6 +201,7 @@ angular.module('chieffancypants.loadingBar', [])
186201
if (includeSpinner) {
187202
$animate.enter(spinner, $parent);
188203
}
204+
189205
_set(0.02);
190206
}
191207

@@ -265,13 +281,14 @@ angular.module('chieffancypants.loadingBar', [])
265281
}
266282

267283
return {
268-
start : _start,
269-
set : _set,
270-
status : _status,
271-
inc : _inc,
272-
complete : _complete,
273-
includeSpinner : this.includeSpinner,
274-
parentSelector : this.parentSelector
284+
start : _start,
285+
set : _set,
286+
status : _status,
287+
inc : _inc,
288+
complete : _complete,
289+
includeSpinner : this.includeSpinner,
290+
latencyThreshold : this.latencyThreshold,
291+
parentSelector : this.parentSelector
275292
};
276293

277294

build/loading-bar.min.css

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/loading-bar.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-loading-bar",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"description": "An automatic loading bar for AngularJS",
55
"main": "src/loading-bar.js",
66
"directories": {

0 commit comments

Comments
 (0)