Hi,
I've been trying to figure out how to make an animation that is basically a timeline. Due to secrecy I can't really show the animation. But it's really easy to explain the issue.
I have two columns.
To the left, I have a bunch of images stacked over each other. (they will change by giving them opacity: 1. )
On the right, I have some text blocks. I want to sync each textblock with the correct image to be shown.
let tl = gsap.timeline({
scrollTrigger: {
trigger: "#timelineSection",
start: "center center",
end: "+=2500",
scrub: 0.5,
pin: true,
}
});
tl
.addClass?//Add a class .active to the correct image, that gives the image opacity 1
.to(".text-1", {opacity: 1, y:0}) //fade in the correct text with scrub
.addClass?//Add a class .active to the next image, that gives the image opacity 1
.to(".text-2", {opacity: 1, y:0})
Why I want to add a class to the image instead of just animating it within the timeline is because I want the opacity animation of each image to NOT scrub. The image should fade in regardless if I the user stops scrolling or something.
So basically, fade in an image by adding the class .active, which contains opacity: 1; and a duration etc. And it should just play. But then you have to scroll through the text animation. When the text is done animating, the class .active gets added to the next image in line.
I can't seem to find a way to toggle a class on a specific element in a timeline with GSAP + ScrollTrigger?
The same effect can be found here: https://www.apple.com/airpods-max/
if you scroll down to the picture attached.