var queue = (function() {
var pending = [];
function next() {
var fn = pending.shift(); //run after will all undeind
if (fn) {
fn(next);
}
}
return function(fn) {
pending.push(fn);
if (pending.length == 1) next();
};
})();
so the code edit after,
queue(function(next) {
// Set positionUsing if it hasn't already been set
if (Settings.positionUsing === '') Settings.positionUsing = NProgress.getPositioningCSS();
// Add transition
css(bar, barPositionCSS(n, speed, ease));
if (n === 1) {
// Fade out
css(progress, {
transition: 'none',
opacity: 1
});
progress.offsetWidth; /* Repaint */
setTimeout(function() {
css(progress, {
transition: 'all ' + speed + 'ms linear',
opacity: 0
});
setTimeout(function() {
NProgress.remove();
//next();
}, speed);
}, speed);
}
// else {
// setTimeout(next, speed); // Significance ?
// }
});
queue callback will is undefind,
so the code edit after,
del after will run no problem,no error. But,i don't know why write this. for a test demo:http://yyman001.github.io/nprogress.js/index.html i want to know it why write this, thanks.