let animHeadingPara = document.querySelectorAll(‘.dm-heading’)
animHeadingPara.forEach((headingElement, index) => {
let splitHeading = new SplitType(headingElement.querySelector(‘h2’), { types: ‘words’ });
let splitParagraph = new SplitType(document.querySelectorAll(‘.dm-paragraph’)[index].querySelector(‘p’));
let headingParaTimeline = gsap.timeline({
scrollTrigger: {
trigger: headingElement,
scroller: ‘body’,
start: ‘top 80%’
}
});
headingParaTimeline
.from(splitHeading.words, {
y: 30,
opacity: 0,
duration: 0.3,
stagger: 0.1
})
.from(splitParagraph.lines, {
y: 30,
opacity: 0,
duration: 0.3,
stagger: 0.1
}, “-=0.2”); // overlap the animations slightly for a smoother effect
});