Skip to content

Commit

Permalink
Prevent progress from starting if event was cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
reinink committed Sep 24, 2020
1 parent 4604c12 commit 1acfcc8
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/progress.js
Expand Up @@ -104,13 +104,19 @@ export default {
document.head.appendChild(element)
},

start() {
this.inProgress++
clearTimeout(this.timeout)
this.timeout = setTimeout(() => {
Nprogress.set(0)
Nprogress.start()
}, this.delay)
start(event) {
Promise.resolve().then(() => {
if (event.defaultPrevented) {
return
}

this.inProgress++
clearTimeout(this.timeout)
this.timeout = setTimeout(() => {
Nprogress.set(0)
Nprogress.start()
}, this.delay)
})
},

progress(event) {
Expand Down

0 comments on commit 1acfcc8

Please sign in to comment.