I have a "Projects" page where I'm showcasing project pieces and I want each one to fade in on scroll. I'm trying to implement a timeline for each project with the following HTML and JavaScript:
<!-- Page contains multiple projects that follow this template -->
<div id="project-trigger">
<div class="project">
<img class="project-image" src="image1" alt="">
<div class="description">
<h3 class="project-text">Lorem Ipsum</h3>
<p class="project-text">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Fuga impedit numquam modi accusamus.</p>
</div>
</div>
</div>
let projectTrigger = document.querySelectorAll('#project-trigger');
projectTrigger.forEach(project => {
let timeline = gsap.timeline({
scrollTrigger:{
trigger:"#project-trigger",
start:"center bottom",
ease:"power2.easeOut",
toggleActions: "play none none reverse",
}
})
timeline.from(".project-image",{
x:-200,
opacity:0,
duration:0.5
}).from(".project-text",{
x:200,
opacity:0,
duration:0.5,
stagger:0.2
}, "-=0.5")
}
)
I want the images to fade in from the left, and the text to fade from the right. At the moment, it's not working - the images fade in halfway then stop, and the text doesn't scroll in at all.
Is it possible to implement what I'm after? And if so, where am I going wrong?
CodePen: https://codepen.io/jacobcollinsdev/pen/jOrpKja?editors=1010