|
18 | 18 |
|
19 | 19 | var Settings = NProgress.settings = {
|
20 | 20 | minimum: 0.08,
|
21 |
| - easing: 'ease', |
| 21 | + easing: 'linear', |
22 | 22 | positionUsing: '',
|
23 |
| - speed: 200, |
| 23 | + speed: 350, |
24 | 24 | trickle: true,
|
25 |
| - trickleRate: 0.02, |
26 |
| - trickleSpeed: 800, |
| 25 | + trickleSpeed: 250, |
27 | 26 | showSpinner: true,
|
28 | 27 | barSelector: '[role="bar"]',
|
29 | 28 | spinnerSelector: '[role="spinner"]',
|
|
83 | 82 |
|
84 | 83 | if (n === 1) {
|
85 | 84 | // Fade out
|
86 |
| - css(progress, { |
87 |
| - transition: 'none', |
88 |
| - opacity: 1 |
| 85 | + css(progress, { |
| 86 | + transition: 'none', |
| 87 | + opacity: 1 |
89 | 88 | });
|
90 | 89 | progress.offsetWidth; /* Repaint */
|
91 | 90 |
|
92 | 91 | setTimeout(function() {
|
93 |
| - css(progress, { |
94 |
| - transition: 'all ' + speed + 'ms linear', |
95 |
| - opacity: 0 |
| 92 | + css(progress, { |
| 93 | + transition: 'all ' + speed + 'ms linear', |
| 94 | + opacity: 0 |
96 | 95 | });
|
97 | 96 | setTimeout(function() {
|
98 | 97 | NProgress.remove();
|
|
161 | 160 |
|
162 | 161 | if (!n) {
|
163 | 162 | return NProgress.start();
|
| 163 | + } else if(n > 1) { |
| 164 | + return; |
164 | 165 | } else {
|
165 | 166 | if (typeof amount !== 'number') {
|
166 |
| - amount = (1 - n) * clamp(Math.random() * n, 0.1, 0.95); |
| 167 | + if (n >= 0 && n < 0.25) { |
| 168 | + // Start out between 3 - 6% increments |
| 169 | + amount = (Math.random() * (5 - 3 + 1) + 3) / 100; |
| 170 | + } else if (n >= 0.25 && n < 0.65) { |
| 171 | + // increment between 0 - 3% |
| 172 | + amount = (Math.random() * 3) / 100; |
| 173 | + } else if (n >= 0.65 && n < 0.9) { |
| 174 | + // increment between 0 - 2% |
| 175 | + amount = (Math.random() * 2) / 100; |
| 176 | + } else if (n >= 0.9 && n < 0.99) { |
| 177 | + // finally, increment it .5 % |
| 178 | + amount = 0.005; |
| 179 | + } else { |
| 180 | + // after 99%, don't increment: |
| 181 | + amount = 0; |
| 182 | + } |
167 | 183 | }
|
168 | 184 |
|
169 | 185 | n = clamp(n + amount, 0, 0.994);
|
|
172 | 188 | };
|
173 | 189 |
|
174 | 190 | NProgress.trickle = function() {
|
175 |
| - return NProgress.inc(Math.random() * Settings.trickleRate); |
| 191 | + return NProgress.inc(); |
176 | 192 | };
|
177 | 193 |
|
178 | 194 | /**
|
|
220 | 236 | if (NProgress.isRendered()) return document.getElementById('nprogress');
|
221 | 237 |
|
222 | 238 | addClass(document.documentElement, 'nprogress-busy');
|
223 |
| - |
| 239 | + |
224 | 240 | var progress = document.createElement('div');
|
225 | 241 | progress.id = 'nprogress';
|
226 | 242 | progress.innerHTML = Settings.template;
|
|
229 | 245 | perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0),
|
230 | 246 | parent = document.querySelector(Settings.parent),
|
231 | 247 | spinner;
|
232 |
| - |
| 248 | + |
233 | 249 | css(bar, {
|
234 | 250 | transition: 'all 0 linear',
|
235 | 251 | transform: 'translate3d(' + perc + '%,0,0)'
|
|
340 | 356 |
|
341 | 357 | var queue = (function() {
|
342 | 358 | var pending = [];
|
343 |
| - |
| 359 | + |
344 | 360 | function next() {
|
345 | 361 | var fn = pending.shift();
|
346 | 362 | if (fn) {
|
|
355 | 371 | })();
|
356 | 372 |
|
357 | 373 | /**
|
358 |
| - * (Internal) Applies css properties to an element, similar to the jQuery |
| 374 | + * (Internal) Applies css properties to an element, similar to the jQuery |
359 | 375 | * css method.
|
360 | 376 | *
|
361 |
| - * While this helper does assist with vendor prefixed property names, it |
| 377 | + * While this helper does assist with vendor prefixed property names, it |
362 | 378 | * does not perform any manipulation of values prior to setting styles.
|
363 | 379 | */
|
364 | 380 |
|
|
399 | 415 |
|
400 | 416 | return function(element, properties) {
|
401 | 417 | var args = arguments,
|
402 |
| - prop, |
| 418 | + prop, |
403 | 419 | value;
|
404 | 420 |
|
405 | 421 | if (args.length == 2) {
|
|
430 | 446 | var oldList = classList(element),
|
431 | 447 | newList = oldList + name;
|
432 | 448 |
|
433 |
| - if (hasClass(oldList, name)) return; |
| 449 | + if (hasClass(oldList, name)) return; |
434 | 450 |
|
435 | 451 | // Trim the opening space.
|
436 | 452 | element.className = newList.substring(1);
|
|
454 | 470 | }
|
455 | 471 |
|
456 | 472 | /**
|
457 |
| - * (Internal) Gets a space separated list of the class names on the element. |
458 |
| - * The list is wrapped with a single space on each end to facilitate finding |
| 473 | + * (Internal) Gets a space separated list of the class names on the element. |
| 474 | + * The list is wrapped with a single space on each end to facilitate finding |
459 | 475 | * matches within the list.
|
460 | 476 | */
|
461 | 477 |
|
462 | 478 | function classList(element) {
|
463 |
| - return (' ' + (element.className || '') + ' ').replace(/\s+/gi, ' '); |
| 479 | + return (' ' + (element && element.className || '') + ' ').replace(/\s+/gi, ' '); |
464 | 480 | }
|
465 | 481 |
|
466 | 482 | /**
|
|
473 | 489 |
|
474 | 490 | return NProgress;
|
475 | 491 | });
|
476 |
| - |
|
0 commit comments