11import { removeElement , addClass , removeClass } from "./dom" ;
2+ import { queue } from "./queue" ;
23import {
34 toBarPerc ,
45 barPositionCSS ,
@@ -58,7 +59,7 @@ function configure(options) {
5859 Settings [ key ] = value ;
5960 }
6061
61- return this ;
62+ return NProgress ;
6263}
6364
6465/**
@@ -75,7 +76,7 @@ function set(n) {
7576 n = clamp ( n , Settings . minimum , 1 ) ;
7677 NProgress . status = n === 1 ? null : n ;
7778
78- var progress = NProgress . render ( ! started ) ,
79+ var progress = render ( ! started ) ,
7980 bar = progress . querySelector ( Settings . barSelector ) ,
8081 speed = Settings . speed ,
8182 ease = Settings . easing ;
@@ -116,7 +117,7 @@ function set(n) {
116117 }
117118 } ) ;
118119
119- return this ;
120+ return NProgress ;
120121}
121122
122123function isStarted ( ) {
@@ -144,7 +145,7 @@ NProgress.start = function () {
144145
145146 if ( Settings . trickle ) work ( ) ;
146147
147- return this ;
148+ return NProgress ;
148149} ;
149150
150151/**
@@ -162,7 +163,7 @@ NProgress.start = function () {
162163 */
163164
164165NProgress . done = function ( force ) {
165- if ( ! force && ! NProgress . status ) return this ;
166+ if ( ! force && ! NProgress . status ) return NProgress ;
166167
167168 inc ( 0.3 + 0.5 * Math . random ( ) ) ;
168169 set ( 1 ) ;
@@ -221,9 +222,11 @@ function getParent() {
221222/**
222223 * (Internal) renders the progress bar markup based on the `template`
223224 * setting.
225+ *
226+ * @param {boolean= } fromStart If true, then it will reset to 0% before starting
224227 */
225228
226- NProgress . render = function ( fromStart ) {
229+ function render ( fromStart ) {
227230 if ( isRendered ( ) ) return document . getElementById ( "nprogress" ) ;
228231
229232 addClass ( document . documentElement , "nprogress-busy" ) ;
@@ -261,7 +264,7 @@ NProgress.render = function (fromStart) {
261264
262265 parent . appendChild ( progress ) ;
263266 return progress ;
264- } ;
267+ }
265268
266269/**
267270 * Removes the element. Opposite of render().
@@ -286,32 +289,13 @@ function isRendered() {
286289 return ! ! document . getElementById ( "nprogress" ) ;
287290}
288291
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-
309292// Default export for commonjs / import NProgress
310293NProgress . configure = configure ;
311294NProgress . inc = inc ;
312295NProgress . isRendered = isRendered ;
313296NProgress . isStarted = isStarted ;
314297NProgress . remove = remove ;
298+ NProgress . render = render ;
315299NProgress . set = set ;
316300NProgress . settings = Settings ;
317301NProgress . trickle = inc ;
@@ -324,6 +308,7 @@ export {
324308 isRendered ,
325309 isStarted ,
326310 remove ,
311+ render ,
327312 set ,
328313 Settings as settings ,
329314} ;
0 commit comments