MurhafSousli / ngx-progressbar

Angular progress bar ☄
https://ngx-progressbar.netlify.app/
MIT License
1.02k stars 101 forks source link

after `progress.done() ` call `progress.start()` will not work #66

Closed xinshangshangxin closed 7 years ago

xinshangshangxin commented 7 years ago

I'm submitting a ... (check one with "x")

[x] bug report => search for a similar issue before submitting
[ ] feature request
[ ] question

Minimal usage of the plugin

demo

plnkr

this.progress.start();
this.progress.done();

setTimeout(() => {
    console.log('this will not start');
    this.progress.start();
}, 400);

setTimeout(() => {
    console.log('this will start');
    this.progress.start();
}, 3000);

reason:

https://github.com/MurhafSousli/ngx-progressbar/blob/master/src/services/progress.service.ts#L110

setTimeout(complete, this.speed);

resolve

I thought should judge the state, like this:

if (n === this.maximum) {
      const hide = () => {
        /**
         *  reset progress
         *  Keep it { 0, false } to fadeOut progress-bar after complete
         */
        if (this.progress === this.maximum) {
          this.progress = 0;
          this.updateState(this.progress, false);
        }
      };
      const complete = () => {
        /**
         * complete progressbar
         * { 1, false } to complete progress-bar before hiding
         */
        if (this.progress === this.maximum) {
          this.updateState(this.progress, false);
          setTimeout(hide, this.speed);
        }
      };
      setTimeout(complete, this.speed);
    }
MurhafSousli commented 7 years ago

Hi @xinshangshangxin Thanks for your feedback.

Right, there is a tiny small interval where the progress is about to complete and fade out.

Have you tried your suggested fix? if it worked, please send me a PR with a plunker and I will merge it.

You can build the module after adding your changes with npm run build, then copy ngx-progressbar.umd.js content into the plunker to test it.

xinshangshangxin commented 7 years ago

done

xinshangshangxin commented 7 years ago

I made a mistake, I'm updating the code, waiting @MurhafSousli I make new PR

MurhafSousli commented 7 years ago

@xinshangshangxin Got it... thanks