2015-05-10 69 views
0

documentation中,它列出了使用插件的各種方法,但它們似乎都需要輸入數字(例如「scrollTo:{y:250}」)。我想知道是否有一種方法可以輸入div ID,而不是數字。有沒有辦法使用GSAP的scrollToPlugin滾動到div ID?

jQuery(document).ready(function($){ 

    $('.full-streams-link').on('click', 'a', function(e) { 
     e.preventDefault(); 

     TweenLite.to(window, .4, { 
      scrollTo: {y:500}, 
      ease: Power2.easeOut, 
      force3D: true 
     }); 

    }); 

}); 

回答

1

Y值,你可以通過在頂部位置:

你可以做

y: $('#element').position().top 
+1

真棒!無論如何,從'#元素'使其爲-10px?編輯:沒關係。我可以在最後加上-10。 – J82

相關問題