I currently have a scrolltrigger setup with GSAP that pins at a point and then scrolls through some slides vertically. All is working as expected. However I'm not sure how to setup an inner timeline inside each of the slides before moving on to the next slide. Ideally what would happen is Slide 1 is showing as is and then the content inside that slide cycles through its content (fade out, fade in) before moving on to the next slide index and so forth.
https://codepen.io/mDDDD/pen/dyWRqJW
const sections = gsap.utils.toArray('.slide');
const innerSections = gsap.utils.toArray('.slide--inner');
const numSections = sections.length - 1;
const snapValue = 1 / numSections;
let oldIndex = 0;
const navList = document.querySelectorAll('.timeline-nav__list-item');
gsap.to(sections, {
yPercent: -100 * numSections,
ease: 'none',
scrollTrigger: {
pin: '#pin',
scrub: true,
snap: snapValue,
markers: true,
end: 'bottom bottom',
onUpdate: (self) => {
const currentIndex = Math.round(self.progress / snapValue);
if (currentIndex !== oldIndex) {
console.log(currentIndex);
navList[oldIndex].classList.remove('is-active');
navList[currentIndex].classList.add('is-active');
oldIndex = currentIndex;
}
},
},
});