Skip to content

Instantly share code, notes, and snippets.

@louisesalas
Created October 19, 2022 22:37
Show Gist options
  • Save louisesalas/3bc945cf1694f770e7447517dfadd682 to your computer and use it in GitHub Desktop.
Save louisesalas/3bc945cf1694f770e7447517dfadd682 to your computer and use it in GitHub Desktop.
$(window).scroll(function(){
var a = 0;
var oTop = $(".counter-container").offset().top - window.innerHeight;
if (a == 0 && $(window).scrollTop() > oTop) {
$('.number-title').each(function () {
var $this = $(this);
jQuery({ Counter: 0 }).animate({ Counter: $this.attr("data-counter") }, {
duration: 2000,
easing: 'swing',
step: function () {
var sign_ = $this.text();
var suffix = ( !FX.CounterJS.isNumber( sign_ ) ) ? sign_ : '';
$this.text(Math.ceil(this.Counter).toLocaleString() + sign_.substring(sign_.length - 1));
}
});
});
a = 1;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment