Skip to content

progressbar.complete() shouldn't animate unless it has been started #126

@javoire

Description

@javoire

Minor enhancement that I think would improve its behaviour. Currently I start the bar if a timer exceeds 300ms, but I always complete it when a state has loaded, but I have to check the .status method to not show it unnecessarily. E.g:

const progressbarTimeouts = []; // can be more than one, in e.g. a redirect
$rootScope.$on('$stateChangeStart', () => {
  progressbarTimeouts.push($timeout(() => progressbar.start(), 300));
});
$rootScope.$on('$stateChangeSuccess', () =>{
  progressbarTimeouts.map((t) => $timeout.cancel(t));
  if (progressbar.status() > 0) { // <--- wouldn't be needed 
    progressbar.complete();
  }
});

It's a very minor "issue" but I think it makes sense that .complete is a noop if it hasn't started. My code would then be:

const progressbarTimeouts = []; // can be more than one, in e.g. a redirect
$rootScope.$on('$stateChangeStart', () => {
  progressbarTimeouts.push($timeout(() => progressbar.start(), 300));
});
$rootScope.$on('$stateChangeSuccess', () =>{
  progressbarTimeouts.map((t) => $timeout.cancel(t));
  progressbar.complete();
});

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions