admin管理员组文章数量:1313386
I've got the following codepen where I'm scrolling a container with overflow hidden. My left column has 3 links, and my right column has the container with 3 blocks of content that correspond to the links.
Here's my codepen:
The scroll is doing what I want, but now I'd like the links on the left to ALSO be clickable to jump to the corresponding content sections on the right.
This is what I'm trying, but it doesn't quite work because it's moving the entire window as opposed to just the content with the container. Any ideas?:
const tabs = document.querySelectorAll('.workplace .transform-work-content .tab-link');
tabs.forEach((tab, index) => {
tab.addEventListener('click', (e) => {
e.preventDefault();
gsap.to(window, {
scrollTo: sections[index],
duration: 1,
ease: "power2.inOut",
});
});
});
I've got the following codepen where I'm scrolling a container with overflow hidden. My left column has 3 links, and my right column has the container with 3 blocks of content that correspond to the links.
Here's my codepen: https://codepen.io/mattmager/pen/WbemwmO
The scroll is doing what I want, but now I'd like the links on the left to ALSO be clickable to jump to the corresponding content sections on the right.
This is what I'm trying, but it doesn't quite work because it's moving the entire window as opposed to just the content with the container. Any ideas?:
const tabs = document.querySelectorAll('.workplace .transform-work-content .tab-link');
tabs.forEach((tab, index) => {
tab.addEventListener('click', (e) => {
e.preventDefault();
gsap.to(window, {
scrollTo: sections[index],
duration: 1,
ease: "power2.inOut",
});
});
});
Share
Improve this question
asked Jan 31 at 0:51
guitar4jcguitar4jc
133 bronze badges
1 Answer
Reset to default 0you fot to register the ScrollToPlugin
try gsap.registerPlugin(ScrollTrigger, ScrollToPlugin);
本文标签: javascriptGSAP ScrollTrigger ScrollTo sectionStack Overflow
版权声明:本文标题:javascript - GSAP ScrollTrigger ScrollTo section - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741930450a2405544.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论