Last active
February 22, 2022 07:28
-
-
Save vibrates09/b7233f8d5458790bf5753f77d311df6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var statsCounter=document.querySelectorAll(".jsStatsCounter");function isInViewport(t){var e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}statsCounter.forEach(t=>{var e=!1;window.addEventListener("scroll",()=>{if(!e){var n=parseInt(t.dataset.start),o=parseInt(t.dataset.end),r=n;t.textContent=n,isInViewport(t)&&(e=!0,setInterval(()=>{r<o?r+=1:r=o,t.textContent=r},25))}},!1)}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unminified version