[英]setInterval timer need offset on animated progress bar
我有一個腳本:
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);
}
我根據intCount
* intTickLength
動畫進度條的寬度(也許有更好的方法?)
問題是,當計數器達到1時,條上的最后一個勾號消失。 我需要它保持到計數器達到0.我需要某種偏移..任何想法? 我不是專家,但我渴望成為一名。
在遞減計數器之前設置條形尺寸:
jQuery('#bar').css('width', intCount * intTickLength + 'px');
jQuery('#timer').html('00:0' + intCount--);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.