How to use nprogress

Comprehensive nprogress code examples:

How to use nprogress.settings:

11
12
13
14
15
16
17
18
19
20
var style = opts.style === false ? '' : '<style>' + css + '</style>'

bar.configure({
  parent: 'parent' in opts ? opts.parent : undefined,
  showSpinner: 'spinner' in opts ? opts.spinner : true,
  template: style + bar.settings.template
})

return function progress (ctx, next) {
  var req = ctx.req

How to use nprogress.configure:

8
9
10
11
12
13
14
15
16
17

var color = 'color' in opts ? opts.color : '#000'
var css = '#nprogress{pointer-events:none}#nprogress .bar{background:' + color + ';position:fixed;z-index:1031;top:0;left:0;width:100%;height:2px}#nprogress .peg{display:block;position:absolute;right:0;width:100px;height:100%;box-shadow:0 0 10px ' + color + ',0 0 5px ' + color + ';opacity:1;-webkit-transform:rotate(3deg) translate(0,-4px);-ms-transform:rotate(3deg) translate(0,-4px);transform:rotate(3deg) translate(0,-4px)}#nprogress .spinner{display:block;position:fixed;z-index:1031;top:15px;right:15px}#nprogress .spinner-icon{width:18px;height:18px;box-sizing:border-box;border:2px solid transparent;border-top-color:' + color + ';border-left-color:' + color + ';border-radius:50%;-webkit-animation:nprogress-spinner .4s linear infinite;animation:nprogress-spinner .4s linear infinite}.nprogress-custom-parent{overflow:hidden;position:relative}.nprogress-custom-parent #nprogress .bar,.nprogress-custom-parent #nprogress .spinner{position:absolute}@-webkit-keyframes nprogress-spinner{0%{-webkit-transform:rotate(0)}100%{-webkit-transform:rotate(360deg)}}@keyframes nprogress-spinner{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}'
var style = opts.style === false ? '' : '<style>' + css + '</style>'

bar.configure({
  parent: 'parent' in opts ? opts.parent : undefined,
  showSpinner: 'spinner' in opts ? opts.spinner : true,
  template: style + bar.settings.template
})

How to use nprogress.set:

87
88
89
90
91
92
93
94
95
96
  processData: false,
  cache: false,
  progress: function(event) {
    if(event.lengthComputable) {
      // 50% when the upload completes
      NProgress.set(event.loaded / event.total * .5);
    }
  }
})
  .done((res) => {

How to use nprogress.start:

193
194
195
196
197
198
199
200
201
202
if(pastedData.match(/^https?:\/\//i)) {
  event.stopPropagation();
  event.preventDefault();

  // Fetch oEmbed code
  NProgress.start();
  $.ajax({
    url: oEmbedAction,
    type: 'GET',
    data: {

How to use nprogress.done:

200
201
202
203
204
205
206
207
208
})

.ajaxStop(function(){
  _.delay(function(){
    if ($.active === 0){
      Nprogress.done();
    }
  }, 100);
})

How to use nprogress.default:

32
33
34
35
36
37
38
39
40
41
if (to.path === '/login') {
  // if is logged in, redirect to the home page
  next({
    path: '/'
  });
  _nprogress.default.done();
} else {
  const hasGetUserInfo = _store.default.getters.name;
  if (hasGetUserInfo) {
    next();