Hi,
I’ve added a code to this page: https://anatbelinson.wixsite.com/lead4bit2 to make the numbers halfway through the page, be animated to show an upwards count. As you can see they are not working properly and their speed is all they same despite the fact that I’ve defined different durations (I probably did something wrong…).
Any help would be appreciated!
Here’s the code:
let startNum = 0;
let endNum = 10;
const duration = 1000; // 1000 milliseconds
let customstartNum = 0;
let customendNum = 225;
const customduration = 500; // 500 milliseconds
let leadsstartNum = 0;
let leadsendNum = 10000;
const leadsduration = 10; // 10 milliseconds
let heartstartNum = 0;
let heartendNum = 100;
const heartduration = 1000; // 10 milliseconds
$w.onReady( function () {
});
function countUp(){
if (startNum <= endNum ){
$w(‘#ten’).text = startNum.toString();
startNum++;
}
if (customstartNum <= customendNum ){
$w(‘#customers’).text = customstartNum.toString();
customstartNum++;
}
if (leadsstartNum <= leadsendNum ){
$w(‘leads’).text = leadsstartNum.toString();
leadsstartNum++;
}
if (heartstartNum <= heartendNum ){
$w(‘#heart’).text = heartstartNum.toString();
heartstartNum++;
}
}
export function ten_viewportEnter(event, $w) {
setInterval(()=> {
countUp();
}, duration);
}
export function customers_viewportEnter(event, $w) {
setInterval(()=> {
countUp();
}, duration);
}
export function leads_viewportEnter(event, $w) {
setInterval(()=> {
countUp();
}, duration);
}
export function heart_viewportEnter(event, $w) {
setInterval(()=> {
countUp();
}, duration);
}