2015-12-02 274 views
1

我想创建锚链接滚动,并与引导类型错误:m.easing [this.easing]是不是一个函数错误

$(window).scroll(function(){ 
    if ($(window).scrollTop() >= 100) { 
     $('#header').addClass('fixed'); 
    } 
    else { 
     $('#header').removeClass('fixed').fadeOut("slow", 100); 
    } 
      $('[data-toggle="tooltip"]').tooltip(); 
}); 


$(function() { 
    $('a.page-scroll').bind('click', function(event) { 
     var $anchor = $(this); 
     $('html, body').stop().animate({ 
      scrollTop: $($anchor.attr('href')).offset().top 
     }, 1500, 'easeInOutExpo'); 
     event.preventDefault(); 
    }); 
}); 

$(function() { 
    $('a.scroll').bind('click', function(event) { 
     var $anchor = $(this); 
     $('html, body').stop().animate({ 
      scrollTop: $($anchor.attr('href')).offset().top 
     }, 1500, 'easeInOutExpo'); 
     event.preventDefault(); 
    }); 
}); 

工具提示显示,但我在控制台 收到此错误类型错误:m.easing [this.easing]不是函数

enter image description here 演示链接 http://itracktraining.com/bb2/index.html

回答

1

按照fadeOut文档,所述第一argum ent应该是动画的持续时间,第二个参数应该是回调。这些持续时间可以是在毫秒(因为你已经把你的第二个参数),或者一个字符串,别名时限。

基本上,您需要更改的下列方式之一您的fadeOut代码:

$('#header').removeClass('fixed').fadeOut("slow"); 

// OR 

$('#header').removeClass('fixed').fadeOut(100); 

您同时还使用easeInOutExpo的宽松政策。 JQuery不会与这个缓解捆绑在一起。见this网页,其中说:

The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

要使用宽松,你需要确保你包括jQuery UI为页面上的外部库。

您还需要jQuery的用户界面的使用方法tooltip的。

+0

错误仍然存​​在,甚至根据你做的更改后.... –

+0

@DivyaSharma请参阅我的更新答案,其中包括对使用fadeOut'的'解释。 – shennan

相关问题