21 lines
543 B
JavaScript
21 lines
543 B
JavaScript
{a4d8e121aeee908500dab70d1c18e70820915755 true 543 main.js 0xc00b080460}
let nums = document.querySelectorAll(".nums .num");
|
|
let section = document.querySelector(".three");
|
|
let started = false; // Function Started ? No
|
|
|
|
window.onscroll = function () {
|
|
if (window.scrollY >= section.offsetTop) {
|
|
if (!started) {
|
|
nums.forEach((num) => startCount(num));
|
|
}
|
|
started = true;
|
|
}
|
|
};
|
|
function startCount(el) {
|
|
let goal = el.dataset.goal;
|
|
let count = setInterval(() => {
|
|
el.textContent++;
|
|
if (el.textContent == goal) {
|
|
clearInterval(count);
|
|
}
|
|
}, 2000 / goal);
|
|
} |