YouTube like top attached progress bar to show $http requests in progress (automatic)

When you include thatisuday.ng-http-progress module to your app's dependencies, you will automatically get progress bar whenever you send ajax requests through $http service.
You can change the background color and other options in config block using $httpProgressOpsProvider provider of ng-http-progress module.
In general, whenever your app send one or more $http requests, progress bar will show up and progress will start. At each second, progress bar width will increment by 5% until it reaches 90%. At 90% progress, progress bar will pause and stay like that until all ajax requests finishes. When all ajax requests finishes, progress bar will reach 100% progress and disappear. If all ajax requests finishes before progress reaches 90%, it will jump to 100% and disappear. You can change pause value of 90% to any number between 0 - 100 in config phase.
It consumes only 2kb (gzipped) and it's very hackable.
bower install ng-http-progress
npm install ng-http-progress
include
ng-http-progress.jsandng-http-progress.cssfromdistdirectory.
angular
.module('demo', ['thatisuday.ng-http-progress'])
.config(function($httpProgressOpsProvider){
$httpProgressOpsProvider.setOps({
background: '#b91f1f',
startAt : 0,
autoPauseAt : 90,
http : true
});
})
all above values are default values, you can avoid any options or entire
configblock if you want.
| option | value | default | role |
|---|---|---|---|
| background | hex/rgba | '#b91f1f' | background color of progress bar |
| startAt | 0 - 100 | 0 | start progress bar with initial progress |
| autoPauseAt | 0 - 100 | 90 | where progress bar will pause until requests resolve |
| http | true/false | true | automatic show/hide progress bar for $http requests |
| duration | int (milliseconds) | 1000 | Increment progress every given duration |
| increment | int | 5 | increment progress (%) by given increment value every above duration |
use
startAt : 30for more realistic effect. Check preview.
If you wish to show progress bar other than just $http requests, then you can use events to show/hide/pause/resume progress bar. Ex. $rootScope.$emit('$httpProgressStart');
| event name | emit from | role |
|---|---|---|
| $httpProgressStart | $rootScope | show/start progress bar |
| $httpProgressPause | $rootScope | pause progress bar |
| $httpProgressResume | $rootScope | resume progress bar |
| $httpProgressRestart | $rootScope | restart progress bar |
| $httpProgressStop | $rootScope | stop/hide progress bar |
You can build this directive with your own customization using gulp.
- Go to repository's parent directory and install all node dev dependencies using
npm install --dev. - Make sure you have gulp install globally. Else use
npm install -g gulpto install gulp globally. - All css for this repository has been generated using sass (.scss), so you need to spend 5 mins to learn basics of sass.
- To build or watch the changes, use command
gulp buildorgulp watch
- Please create an issue if you need some help or report a bug.
- Take a pull request to add more features or fix the bugs. Please mention your changes in the PR.
- Please make sure you recommend good practices if you came/come across any or if something could have been better in this module.