The blue outlined areas are the unordered lists within the pinned div that wraps everything:
&__list {
width: 100%;
height: calc(100vh - 100px);
outline: 5px solid skyblue;
outline-offset: -5px;
margin: 0;
padding: 0;
}
They have a height of 100vh - 100px (to account for the navigation being 100px high).
This height allows me to apply a ScrollTrigger on them:
lists.forEach((list, index) => {
const items = list.querySelectorAll('.c-flyway__item');
const itemsTl = gsap.timeline({
scrollTrigger:{
id: `List ${index}`,
trigger: list,
start: "top top",
end: "bottom top",
scrub: true,
markers: true
}
});
items.forEach(item => {
gsap.set(item, { opacity: 0 });
itemsTl.to(item, { opacity: 1 });
itemsTl.to(item, { opacity: 0 });
});
tl.add(itemsTl);
});
Within each lists timeline/scrolltrigger I loop the list items and add them into this timeline with a fade in and out.
However, each list item is position: absolute; because I wanted them all stacked on top of one another in the same place. That, unfortunately means that the lists occupy an area/space below that (visuallly) is not desirable - because the fading in and out has now complete.
There might be a better way to achieve a crossfade effect between all items but I couldn't think of one.