Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions nprogress.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

var Settings = NProgress.settings = {
minimum: 0.08,
delay: 50,
easing: 'linear',
positionUsing: '',
speed: 200,
Expand Down Expand Up @@ -111,13 +112,21 @@
};

/**
* Shows the progress bar.
* Shows the progress bar after the delay.
* This is the same as setting the status to 0%, except that it doesn't go backwards.
*
* NProgress.start();
*
*/
NProgress.start = function() {
NProgress.start = function () {
this.clearDelay();
this.startDelay = setTimeout(function () {
NProgress.doStart();
}, Settings.delay || 0);
};


NProgress.doStart = function() {
if (!NProgress.status) NProgress.set(0);

var work = function() {
Expand Down Expand Up @@ -146,6 +155,7 @@
*/

NProgress.done = function(force) {
this.clearDelay();
if (!force && !NProgress.status) return this;

return NProgress.inc(0.3 + 0.5 * Math.random()).set(1);
Expand Down Expand Up @@ -180,6 +190,13 @@
return NProgress.inc();
};

NProgress.clearDelay = function () {
if (this.startDelay) {
clearTimeout(this.startDelay);
this.startDelay = undefined;
}
};

/**
* Waits for all supplied jQuery promises and
* increases the progress as the promises resolve.
Expand Down