I'm having trouble getting this section to do what I want. I'm brand new to gsap, so I'm sure I'm not even close...
Here's my codepen: https://codepen.io/mattmager/pen/WbemwmO
ScrollTrigger.create({
y: 0,
trigger: ".workplace .transform-work-content",
start: 'top top',
end: 'bottom center',
pin: ".workplace .transform-work-content .tabs",
scrub: true,
markers: true
});
In short, I have 2 columns. The left col contains 3 links. The right col contains 3 corresponding blocks of content within a div that is set to overflow hidden. I want the entire section to pin to the page when scrolled into view, then the content on the right will scroll into view within the container as you continue scrolling, until it reaches the bottom, at which time it unpins and the scrolling continues down the page as normal.
Ultimately, I'd like the links on the left to ALSO be clickable to jump to the corresponding content sections on the right, but first, I just need to get the scrolling functionality working! Any help please!?
UPDATE: I think I got the scrolling where I want it now, but making the links clickable is proving tricky now because of the content being inside a container with the overflow.
This is what I have atm, but it scrolls the whole screen, when I want/need it to only scroll the content in 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",
});
});
});