1
1
import { removeElement , addClass , removeClass } from "./dom" ;
2
+ import { queue } from "./queue" ;
2
3
import {
3
4
toBarPerc ,
4
5
barPositionCSS ,
@@ -58,7 +59,7 @@ function configure(options) {
58
59
Settings [ key ] = value ;
59
60
}
60
61
61
- return this ;
62
+ return NProgress ;
62
63
}
63
64
64
65
/**
@@ -75,7 +76,7 @@ function set(n) {
75
76
n = clamp ( n , Settings . minimum , 1 ) ;
76
77
NProgress . status = n === 1 ? null : n ;
77
78
78
- var progress = NProgress . render ( ! started ) ,
79
+ var progress = render ( ! started ) ,
79
80
bar = progress . querySelector ( Settings . barSelector ) ,
80
81
speed = Settings . speed ,
81
82
ease = Settings . easing ;
@@ -116,7 +117,7 @@ function set(n) {
116
117
}
117
118
} ) ;
118
119
119
- return this ;
120
+ return NProgress ;
120
121
}
121
122
122
123
function isStarted ( ) {
@@ -144,7 +145,7 @@ NProgress.start = function () {
144
145
145
146
if ( Settings . trickle ) work ( ) ;
146
147
147
- return this ;
148
+ return NProgress ;
148
149
} ;
149
150
150
151
/**
@@ -162,7 +163,7 @@ NProgress.start = function () {
162
163
*/
163
164
164
165
NProgress . done = function ( force ) {
165
- if ( ! force && ! NProgress . status ) return this ;
166
+ if ( ! force && ! NProgress . status ) return NProgress ;
166
167
167
168
inc ( 0.3 + 0.5 * Math . random ( ) ) ;
168
169
set ( 1 ) ;
@@ -221,9 +222,11 @@ function getParent() {
221
222
/**
222
223
* (Internal) renders the progress bar markup based on the `template`
223
224
* setting.
225
+ *
226
+ * @param {boolean= } fromStart If true, then it will reset to 0% before starting
224
227
*/
225
228
226
- NProgress . render = function ( fromStart ) {
229
+ function render ( fromStart ) {
227
230
if ( isRendered ( ) ) return document . getElementById ( "nprogress" ) ;
228
231
229
232
addClass ( document . documentElement , "nprogress-busy" ) ;
@@ -261,7 +264,7 @@ NProgress.render = function (fromStart) {
261
264
262
265
parent . appendChild ( progress ) ;
263
266
return progress ;
264
- } ;
267
+ }
265
268
266
269
/**
267
270
* Removes the element. Opposite of render().
@@ -286,32 +289,13 @@ function isRendered() {
286
289
return ! ! document . getElementById ( "nprogress" ) ;
287
290
}
288
291
289
- /**
290
- * (Internal) Queues a function to be executed.
291
- */
292
-
293
- var queue = ( function ( ) {
294
- var pending = [ ] ;
295
-
296
- function next ( ) {
297
- var fn = pending . shift ( ) ;
298
- if ( fn ) {
299
- fn ( next ) ;
300
- }
301
- }
302
-
303
- return function ( fn ) {
304
- pending . push ( fn ) ;
305
- if ( pending . length == 1 ) next ( ) ;
306
- } ;
307
- } ) ( ) ;
308
-
309
292
// Default export for commonjs / import NProgress
310
293
NProgress . configure = configure ;
311
294
NProgress . inc = inc ;
312
295
NProgress . isRendered = isRendered ;
313
296
NProgress . isStarted = isStarted ;
314
297
NProgress . remove = remove ;
298
+ NProgress . render = render ;
315
299
NProgress . set = set ;
316
300
NProgress . settings = Settings ;
317
301
NProgress . trickle = inc ;
@@ -324,6 +308,7 @@ export {
324
308
isRendered ,
325
309
isStarted ,
326
310
remove ,
311
+ render ,
327
312
set ,
328
313
Settings as settings ,
329
314
} ;
0 commit comments