1

How to run jquery countTo plugin when scrolling one time?

$(window).scroll(function(){
   $(".fact-to:in-viewport").countTo({
        speed: 500,
        refreshInterval: 2
   });
});
Mykola
  • 3,152
  • 6
  • 20
  • 39
BlahBlag
  • 13
  • 2

1 Answers1

1

Add a flag:

var countFlag = false;

$(window).scroll(function(){
  if(!countFlag) {
    countFlag = true;
    $(".fact-to:in-viewport").countTo({
      speed: 500,
      refreshInterval: 2
    });
  }
});

Or unbind event handler

Community
  • 1
  • 1
Artem
  • 783
  • 7
  • 14