Skip to content

Commit ba064b9

Browse files
committed
add push and pop methods
exposes functionality so that loading bar progress can be customized more easily added unit tests for this new functionlity added push and pop functionality to the description of the service API in the readme added setting autoIncrement to the configuration section of the readme
1 parent 8c7853c commit ba064b9

File tree

3 files changed

+318
-275
lines changed

3 files changed

+318
-275
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,15 @@ $http.post('/save', data, {
152152

153153
```
154154

155+
#### Auto Increment
156+
By default, the loading bar will increment by a random amount that get's smaller as the bar fills, you can disable this:
155157

158+
```js
159+
angular.module('myApp', ['angular-loading-bar'])
160+
.config(['cfpLoadingBarProvider', function(cfpLoadingBarProvider) {
161+
cfpLoadingBarProvider.autoIncrement = false;
162+
}])
163+
```
156164

157165

158166
## How it works:
@@ -190,7 +198,17 @@ cfpLoadingBar.status() // Returns the loading bar's progress.
190198

191199
cfpLoadingBar.complete()
192200
// Set the loading bar's progress to 100%, and then remove it from the DOM.
193-
201+
//
202+
// Alternatively, you can us push() and pop() to control the loading bar
203+
// It is suggested that you turn off autoIncrement if you plan on using this
204+
cfpLoadingBar.push(x)
205+
// starts the loading bar if it hasn't been already, and adds to number of 'requests' for this loading bar
206+
// it will broadcast x on the 'cfpLoadingBar:loading' event when called
207+
cfpLoadingBar.pop(y)
208+
// increments the number of requests that have been completed
209+
// then, if the number of 'requests completed' is greater or equal to the number of 'requests' on this bar, it calls complete
210+
// and broadcasts y on the 'cfpLoadingBar:loaded' event
211+
// otherwise, it sets the bar's progress to the number of 'requests completed' divided by the number of 'requests' on this loading bar
194212
```
195213

196214
## Events

0 commit comments

Comments
 (0)