Skip to content

Commit

Permalink
Bootstrap progress-bar animation improved
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzobruni committed Oct 23, 2019
1 parent 073b25b commit f90d333
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/js/api.library.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ api.spinner.progress.start = function (progressTimeout) {
api.spinner.progress.timeout = progressTimeout;

// Set progress to 0%
$(C_API_SELECTOR_SPINNER + " .progress").fadeOut('slow');
$(C_API_SELECTOR_SPINNER + " .progress").find("[name=bar]").css('width', '0%').attr('aria-valuenow', 0);
$(C_API_SELECTOR_SPINNER + " .progress").find("[name=percentage]").text("0%");
$(C_API_SELECTOR_SPINNER + " .progress").find("[name=bar]").css('width', '1%').attr('aria-valuenow', 1);
$(C_API_SELECTOR_SPINNER + " .progress").find("[name=percentage]").text("1%");
$(C_API_SELECTOR_SPINNER + " .progress").show();

// Initiate the progress by setting the timeout
api.spinner.progress.setTimeout();
Expand All @@ -76,9 +76,9 @@ api.spinner.progress.stop = function () {
clearTimeout(api.spinner.progress.instance);

// Set progress to 100%
$(C_API_SELECTOR_SPINNER + " .progress").fadeOut('slow');
$(C_API_SELECTOR_SPINNER + " .progress").find("[name=bar]").css('width', '100%').attr('aria-valuenow', 100);
$(C_API_SELECTOR_SPINNER + " .progress").find("[name=percentage]").text("100%");
$(C_API_SELECTOR_SPINNER + " .progress").fadeOut('slow');
};

/**
Expand All @@ -100,7 +100,6 @@ api.spinner.progress.setTimeout = function () {
api.spinner.progress.instance = setTimeout(function () {
// Never display 100% as it may need longer than expected to complete
var percentage = Math.min(parseInt($(C_API_SELECTOR_SPINNER + " .progress").find("[name=bar]").attr('aria-valuenow')) + 1, 99);
$(C_API_SELECTOR_SPINNER + " .progress").show();
$(C_API_SELECTOR_SPINNER + " .progress").find("[name=bar]").css('width', percentage + '%').attr('aria-valuenow', percentage);
$(C_API_SELECTOR_SPINNER + " .progress").find("[name=percentage]").text(percentage + "%");
// Loop in
Expand Down

0 comments on commit f90d333

Please sign in to comment.