有没有办法使用 GSAP 的 scrollToPlugin 滚动到 div ID?
Is there a way to use GSAP's scrollToPlugin to scroll to a div ID?
在documentation中列出了多种使用插件的方法,但似乎都需要输入数字(例如"scrollTo:{y:250}")。我想知道是否有一种方法可以输入 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
});
});
});
y值可以传入位置top:
你可以
y: $('#element').position().top
从 GSAP 版本 1.19.0 开始,您可以通过以下方式轻松完成:
TweenLite.to(window, 2, {scrollTo:"#someID"});
您可以在以下位置找到更多信息:ScrollToPlugin Documentation
在documentation中列出了多种使用插件的方法,但似乎都需要输入数字(例如"scrollTo:{y:250}")。我想知道是否有一种方法可以输入 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
});
});
});
y值可以传入位置top:
你可以
y: $('#element').position().top
从 GSAP 版本 1.19.0 开始,您可以通过以下方式轻松完成:
TweenLite.to(window, 2, {scrollTo:"#someID"});
您可以在以下位置找到更多信息:ScrollToPlugin Documentation