2
It is possible an infinite and accumulative counter where the puddle determines the time it will increase, for example:
Every 1 minute the number goes up, 3.001, 3.002, 3.003, and so on. And also it cannot be restarted every refresh.
I’m currently using the following code, it serves me but not 100% the way I want it.
$('.count').each(function() {
$(this).prop('Counter', 0).animate({
Counter: $(this).text()
}, {
duration: 200000,
easing: 'swing',
step: function(now) {
$(this).text(commaSeparateNumber(Math.ceil(now)));
}
});
});
function commaSeparateNumber(val) {
while (/(\d+)(\d{3})/.test(val.toString())) {
val = val.toString().replace(/(\d+)(\d{3})/, '$1' + '.' + '$2');
}
return val;
}
Why don’t you save the start moment of the countdown in the localstorage or cookie and then read "the time that’s passed" from that moment on? You need to have this value in a string with format x.xxx?
– Sergio
Yes I need to have in this format, to follow a pattern of other numbers that I have on the same screen but that are not counters... I’ll take a look at this option you suggested.
– user27585