Hey everyone!
I was wondering if it possible to :
first, create a Timeline
then, on each tween, apply a ScrollTrigger with a different trigger for each element.
The idea is to create a timeline where I can create animation for each element .hero, .infos, .other and the triggers would be these classes.
<section>
<div class="hero">
<h1>Title</h1>
</div>
<div class="infos">
<div>
<p>blablabla</p>
</div>
</div>
<div class="other">
<div>
<h2>Subtitle</h2>
</div>
</div>
</section>
Maybe I can do something like this but it creates multiple ScrollTrigger reference.
const tweensConfig = [
{
type: "to",
classname: ".hero",
x: 100,
},
{
type: "from",
classname: ".infos",
opacity: 1,
},
]
const createAnimation = () => itemsClass.map(({ type, classname, ...rest }) =>
gsap[type](classname, { scrollTrigger: { trigger: classname }, ...rest }))
Sorry in advance if I did a duplicated post and I just read the common mistakes usage for ScrollTrigger but I can't find a solution.
Many thanks for your help