Skip to content
This repository has been archived by the owner on Apr 3, 2022. It is now read-only.

Commit

Permalink
Provide delay configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
fracz authored Jan 22, 2019
1 parent a0ab16c commit eabdd98
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions nprogress.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,30 @@
return NProgress.inc();
};

// delay extension, see https://github.com/rstacruz/nprogress/issues/169#issuecomment-456312510

NProgress.doStart = NProgress.start;
NProgress.doDone = NProgress.done;

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

NProgress.start = function () {
this.clearDelay();
this.startDelay = setTimeout(function () {
NProgress.doStart();
}, this.settings.delay || 0);
};

NProgress.done = function () {
this.clearDelay();
this.doDone();
};

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

0 comments on commit eabdd98

Please sign in to comment.