滚动一次时如何运行jquery countTo插件?

时间:2016-01-16 20:16:28

标签: jquery

滚动一次时如何运行jquery countTo插件?

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

1 个答案:

答案 0 :(得分:1)

添加标志:

var countFlag = false;

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

unbind event handler