How to animate numbers when the user sees?

I need to animate the numbers when the user scrolls to them article.
the script of the animation I don't need
need just the right event
June 14th 19 at 18:53
4 answers
June 14th 19 at 18:55
Solution
var currentNumber = $('#fun-level').text();
var cc = 1;

$(window).scroll(function() {
$('#fun-level').each(function(){
 var cPos = $(this).offset().top;
 var topWindow = $(window).scrollTop();

 if (cPos < topWindow + 1000) {
 if (cc < 2) {
 cc = cc + 3;
 $({numberValue: currentNumber}).animate({numberValue: 40}, {
 duration: 2000,
 easing: 'linear',
 step: function() { 
 $('#fun-level').text(Math.ceil(this.numberValue)); 
}
});
 } 
 } 
});
});
June 14th 19 at 18:57
scroll
June 14th 19 at 18:59
$(window).on('scroll', function() { // the scroll event
 if ($('#element').visible(true)) { // visibility check
 // animation here
}
})
June 14th 19 at 19:01

Find more questions by tags JavaScriptjQuery