Contagem + Aleatória
Boas,
Como posso colocar o script mais aleatório, e não apenas uma contagem de 5 em 5 ..
Eu queria, por exemplo, uma contagem de 5 numeros a seguir de 7, depois de 3, depois de 6 ou 15 etc .... uma contagem mais aleatória e não apenas 5 em 5 ou 2 em 2 etc.
<script>
function handleTickInit(tick) {
// update the value every 5 seconds
var interval = Tick.helper.duration(5, 'seconds');
// value to add each interval
var valuePerInterval = 5;
// offset is a fixed date in the past
var offset = Tick.helper.date('2017-03-01');
// uncomment lines below (and comment line above) if you want offset be set to the first time the user visited the page
// var offset = parseInt(localStorage.getItem('tick-value-counter-offset') || Date.now(), 10);
// localStorage.setItem('tick-value-counter-offset', offset);
// start updating the counter each second
Tick.helper.interval(function(){
// current time in milliseconds
var now = Date.now();
// difference with offset time in milliseconds
var diff = now - offset;
// total time since offset divide by interval gives us the amount of loops since offset
var loops = diff / interval;
// this will make sure we only count completed loops.
loops = Math.floor(loops);
// multiply that by the value per interval and you have your final value
tick.value = loops * valuePerInterval;
}, 1000);
}
</script>
Não sei se deu para perceber o que queria..
Obrigado,
Abraço ;)Discussão (10)
Carregando comentários...