0

我正在设计一个单页滚动网页。在网页中,我在技能页面中使用了简单的饼图。现在我想在到达技能页面时加载简单的饼图动画。我使用了航点 js,但它不起作用。当我在技能页面时它会加载动画,但是当我在顶部并刷新页面&而不是转到技能页面时,它不起作用。

我的代码如下

自定义.js:

jQuery('.skill').waypoint(function() {
$('.chart1').easyPieChart({
animate: 4000,
barColor: '#000',
trackColor: '#ddd',
scaleColor: '#e1e1e3',
lineWidth: 15,
size: 152,
});
}, {
triggerOnce: true,
offset: 'bottom-in-view'
});

现在我该如何解决这个问题?

4

1 回答 1

0

你可以试试这段代码:

    $(window).scroll( function(){

    /* Check the location of each desired element */
    $('.skill').each( function(i){

        var bottom_of_object = $(this).offset().top + $(this).outerHeight();
        var bottom_of_window = $(window).scrollTop() + $(window).height();

        /* If the object is completely visible in the window, fade it in */
        if( bottom_of_window > bottom_of_object ){

        $('.skill').easyPieChart({
          size: 140,
          lineWidth: 6,
          lineCap: "square",
          barColor: "#22a7f0",
          trackColor: "#ffffff",
          scaleColor: !1,
          easing: 'easeOutBounce',
          animate: 5000,
          onStep: function(from, to, percent) {
          $(this.el).find('.percent').text(Math.round(percent));
          }
        });

        }

    }); 

});
于 2016-01-07T15:41:16.180 回答