I have a script:
jQuery(document).ready(function() {
timer(10)
});
// Timer
var GLOBAL_TIMER;
function timer(intCount) {
GLOBAL_TIMER = setInterval(function() {
var intTickLength = 10;
if (intCount < 10) {
jQuery('#timer').html('00:0' + intCount--);
jQuery('#bar').css('width', intCount * intTickLength + 'px');
} else {
jQuery('#timer').html('00:' + intCount--);
jQuery('#bar').css('width', intCount * intTickLength + 'px');
}
if (intCount < 0) {
stopTimer();
}
}, 1000);
}
function stopTimer() {
clearInterval(GLOBAL_TIMER);
}
I’m animating the width of the progress bar based on the intCount * intTickLength (maybe there’s a better way?)
Problem is, when the counter reaches 1, the last tick on the bar disappears. I need it to remain until counter reaches 0. I need some kind of an offset.. Any ideas? I’m no js expert, but I long to be one.
Set the bar size before you decrement the counter: