| 1 |
document.addEventListener("DOMContentLoaded",()=>{const e=document.querySelectorAll(".blockspare-counter"),t=new IntersectionObserver((e,t)=>{e.forEach(e=>{e.isIntersecting&&((e=>{const t=parseInt(e.dataset.count,10),n=performance.now(),o=r=>{const a=Math.min((r-n)/2e3,1),s=1-Math.pow(1-a,3),c=Math.floor(s*t);e.textContent=c,a<1?requestAnimationFrame(o):e.textContent=t};requestAnimationFrame(o)})(e.target),t.unobserve(e.target))})},{threshold:.5});e.forEach(e=>t.observe(e))}); |