Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/418.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 到达航路点后不重复该功能_Javascript_Jquery_Jquery Waypoints - Fatal编程技术网

Javascript 到达航路点后不重复该功能

Javascript 到达航路点后不重复该功能,javascript,jquery,jquery-waypoints,Javascript,Jquery,Jquery Waypoints,下面是航路点调用和图形栏函数的JS。每次到达航路点时,它都会重复,我希望它能够识别出该航路点已经到达过一次,并且不重复该功能。谢谢你的帮助 $.getScript('http://imakewebthings.com/jquery-waypoints/waypoints.min.js', function() { $('#jack_bellamy').waypoint(function() { setTimeout(function start (){ $

下面是航路点调用和图形栏函数的JS。每次到达航路点时,它都会重复,我希望它能够识别出该航路点已经到达过一次,并且不重复该功能。谢谢你的帮助

$.getScript('http://imakewebthings.com/jquery-waypoints/waypoints.min.js', function() {

    $('#jack_bellamy').waypoint(function() {
        setTimeout(function start (){

      $('.bar').each(function(i)
      {  
        var $bar = $(this);
        $(this).append('<span class="count"></span>')
        setTimeout(function(){
          $bar.css('width', $bar.attr('data-percent'));     
        }, i*100);
      });

    $('.count').each(function () {
        $(this).prop('Counter',0).animate({
            Counter: $(this).parent('.bar').attr('data-percent')
        }, {
            duration: 2000,
            easing: 'swing',
            step: function (now) {
                $(this).text(Math.ceil(now) +'%');
            }
        });
    });

    }, 500)

    });
    });

如果你不想让航路点一直触发,你可以使用它。为了确保它只运行一次,您可以在处理程序末尾销毁它。this关键字是指可以在处理程序中调用destroy的航路点实例

$('#jack_bellamy').waypoint(function() {
  // all that animation stuff you mentioned
  this.destroy();
});

如果你不想让航路点一直触发,你可以使用它。为了确保它只运行一次,您可以在处理程序末尾销毁它。this关键字是指可以在处理程序中调用destroy的航路点实例

$('#jack_bellamy').waypoint(function() {
  // all that animation stuff you mentioned
  this.destroy();
});