|
6 | 6 | var NProgress = {}; |
7 | 7 |
|
8 | 8 | var Settings = NProgress.settings = { |
9 | | - minimum: 0.1, |
10 | | - exitmode: 'full', |
| 9 | + minimum: 0.05, |
11 | 10 | easing: 'ease', |
12 | | - speed: 300, |
| 11 | + speed: 200, |
13 | 12 | template: '<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner"><div></div></div>' |
14 | 13 | }; |
15 | 14 |
|
|
24 | 23 | $.extend(Settings, options); |
25 | 24 | }; |
26 | 25 |
|
| 26 | + /** |
| 27 | + * Last number. |
| 28 | + */ |
| 29 | + |
27 | 30 | NProgress.status = null; |
28 | 31 |
|
29 | 32 | /** |
|
35 | 38 |
|
36 | 39 | NProgress.set = function(n) { |
37 | 40 | n = clamp(n, Settings.minimum, 1); |
38 | | - NProgress.status = n; |
| 41 | + NProgress.status = (n === 1 ? null : n); |
39 | 42 |
|
40 | 43 | var $progress = NProgress.render(), |
41 | 44 | $bar = $progress.find('[role~="bar"]'), |
|
70 | 73 | }, 0); |
71 | 74 | }; |
72 | 75 |
|
| 76 | + /** |
| 77 | + * Shows the progress bar. |
| 78 | + * This is the same as setting the status to 0%. |
| 79 | + * |
| 80 | + * NProgress.show(); |
| 81 | + * |
| 82 | + */ |
| 83 | + NProgress.show = function() { |
| 84 | + return NProgress.set(0); |
| 85 | + }; |
| 86 | + |
73 | 87 | /** |
74 | 88 | * Hides the progress bar. |
| 89 | + * This is the same as setting the status to 100%. |
75 | 90 | * |
76 | 91 | * NProgress.hide(); |
77 | 92 | */ |
|
80 | 95 | return NProgress.set(1); |
81 | 96 | }; |
82 | 97 |
|
| 98 | + /** |
| 99 | + * Increments by a random amount. |
| 100 | + */ |
| 101 | + |
| 102 | + NProgress.inc = function() { |
| 103 | + var n = NProgress.status; |
| 104 | + |
| 105 | + if (!n) { |
| 106 | + return NProgress.show(); |
| 107 | + } else { |
| 108 | + n += (1 - n) * clamp(Math.random() * n, 0.1, 0.95); |
| 109 | + n = clamp(n, 0, 0.994); |
| 110 | + return NProgress.set(n); |
| 111 | + } |
| 112 | + }; |
| 113 | + |
83 | 114 | /** |
84 | 115 | * (Internal) renders the progress bar markup based on the `template` |
85 | 116 | * setting. |
|
97 | 128 | transform: 'translate3d(-100%,0,0)' |
98 | 129 | }); |
99 | 130 |
|
100 | | - $el[0].innerWidth; |
101 | | - |
102 | 131 | return $el; |
103 | 132 | }; |
104 | 133 |
|
|
110 | 139 | return ($("#nprogress").length > 0); |
111 | 140 | }; |
112 | 141 |
|
113 | | - /** |
114 | | - * Shows the progress bar. |
115 | | - * |
116 | | - */ |
117 | | - NProgress.show = function() { |
118 | | - return NProgress.set(NProgress.settings.minimum); |
119 | | - }; |
120 | | - |
121 | 142 | /** |
122 | 143 | * Helpers |
123 | 144 | */ |
|
0 commit comments