The general idea is is a progress bar that updates the totals and percentage continually.
This just gets a bit choppy when I trigger a few of these independently on the same page. I'm doing a bit of math at every step, and wonder if there is a better way to accomplish this.
$bar.animate({width:percent+"%"}, {
duration : o.time,
easing : 'swing',
complete : function() {
$amount.text('$'+amount.toFixed(2));
$diff.text('$'+(o.max - amount).toFixed(2));
$percent.text(Math.floor(percent));
},
step : function(now, fx) {
var actual_amount = (now / 100) * o.max;
$percent.text(Math.floor(now));
$amount.text('$'+actual_amount.toFixed(2));
$diff.text('$'+(o.max - actual_amount).toFixed(2));
if (o.warning.warning !== 0) {
if (now > o.warning.alert) {
$bar.css("background-color", o.alert_color);
}
else if (now > o.warning.warning) {
$bar.css("background-color", o.warning_color);
}
else {
$bar.css("background-color", beginning_color);
}
}
},
});