这是用于路径点调用和图条函数的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)
});
});发布于 2015-01-29 00:25:21
如果你不想要一个方法点继续触发,你可以销毁它。为了确保它只运行一次,可以在处理程序的末尾销毁它。this关键字引用可以在处理程序中调用The的路径点实例。
$('#jack_bellamy').waypoint(function() {
// all that animation stuff you mentioned
this.destroy();
});https://stackoverflow.com/questions/28113152
复制相似问题