2015-12-02 269 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

相關問題