Hello, I am attempting to add a Number Counter found on wixcreate however I can not figure out a way to change the interval at which the numbers go up. My problem is that my first two numbers are 100 and 600 but my third number is 15,000 so I need it to go up drastically faster. I’ve attached a video of what the problem looks like.
I’ve tried changing the duration all the way down to zero and it still takes forever to get to 15,000. I think I need to change the interval between each step up. Like if I could make it count up by hundreds rather than by 1s that would be perfect but I can’t figure out how to do that. Any help is super appreciated!
Here is my code:
// Counter1 //
$w.onReady(function () {});
let startNum1 = 0;
let endNum1 = 100;
const duration1 = 3; // 1000 milliseconds
$w.onReady(function () {
setInterval(()=> {
countUp1();
}, duration1);
});
function countUp1(){
if (startNum1 <= endNum1 ){
$w('#StartNumber1').text = startNum1.toString();
startNum1++;
}
}
// Counter2 //
$w.onReady(function () {});
let startNum2 = 0;
let endNum2 = 600;
const duration2 = 2; // 1000 milliseconds
$w.onReady(function () {
setInterval(()=> {
countUp2();
}, duration2);
});
function countUp2(){
if (startNum2 <= endNum2 ){
$w('#StartNumber2').text = startNum2.toString();
startNum2++;
}
}
// Counter3 //
$w.onReady(function () {});
let startNum3 = 0;
let endNum3 = 15000;
const duration3 = 0; // 1000 milliseconds
$w.onReady(function () {
setInterval(()=> {
countUp3();
}, duration3);
});
function countUp3(){
if (startNum3 <= endNum3 ){
$w('#StartNumber3').text = startNum3.toString();
startNum3++;
}
}