Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ Changes the minimum percentage used upon starting. (default: `0.08`)
NProgress.configure({ minimum: 0.1 });
~~~

#### `maximum`
Changes the maximum percentage the bar will increment to. (default: `0.994`)

~~~ js
NProgress.configure({ minimum: 0.1 });
~~~

#### `template`
You can change the markup using `template`. To keep the progress
bar working, keep an element with `role='bar'` in there. See the [default template]
Expand Down
3 changes: 2 additions & 1 deletion 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,
maximum: 0.994,
easing: 'linear',
positionUsing: '',
speed: 200,
Expand Down Expand Up @@ -171,7 +172,7 @@
else { amount = 0; }
}

n = clamp(n + amount, 0, 0.994);
n = clamp(n + amount, 0, Settings.maximum);
return NProgress.set(n);
}
};
Expand Down
6 changes: 6 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@
assert.operator(NProgress.status, '>', start);
});

it('should respect maximum', function() {
NProgress.configure({ maximum: 0.8 });
for (var i=0; i<100; ++i) { NProgress.inc(); }
assert.equal(NProgress.status, NProgress.settings.maximum);
});

it('should never reach 1.0', function() {
for (var i=0; i<100; ++i) { NProgress.inc(); }
assert.operator(NProgress.status, '<', 1.0);
Expand Down