JSFiddle - React, Tailwind, and code Playground
HTML
<p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p>
<span class="Count">6666</span>
<br/>
<span class="Count">66666666</span>
<br/>
<span class="Count">66666666</span>
<p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p>
JavaScript
/*$('.Count').each(function () {
var $this = $(this);
jQuery({ Counter: 0 }).animate({ Counter: $this.text() }, {
duration: 1000,
easing: 'swing',
step: function (i) {
$this.text(Math.ceil(i));
}
});
});*/
$(window).bind('scroll', function() {
$('.Count').each(function (i, counter) {
var $this = $(counter);
if ( ($(window).scrollTop() + $(window).height()) > $this.offset().top && !$this.hasClass('started')) {
$this.addClass('started');
jQuery({ Counter: 0 }).animate({ Counter: $this.text() }, {
duration: 1000,
easing: 'swing',
step: function (i) {
$this.text(Math.ceil(i));
},
complete : function() {
},
});
}
});
});