var windowHeight = $(window).height();
$(document).on('scroll', function() {
$('.counter').each(function() {
var self = $(this),
height = self.offset().top + self.height();
if ($(document).scrollTop() + windowHeight >= height) {
$('.counter').each(function() {
$(this).prop('Counter', $(this).data('from')).animate({
Counter: $(this).text()
}, {
duration: $(this).data('duration'),
easing: 'swing',
step: function(now) {
$(this).text(Math.ceil(now))
}
})
});
}
});
});