Hello, I have a page where I am triggering animations within sections as they come into view using the following code:
gsap.utils.toArray('[data-animate]').forEach((elem) => {
const hasPinnedText = !!elem.querySelector('.c-videoBlock--pinned');
ScrollTrigger.create({
trigger: elem,
start: hasPinnedText ? 'top 100%' : 'top 70%',
end: 'bottom bottom',
once: true,
onEnter: () => {
elem.classList.add('animate');
},
});
});
This works as expected on desktop. The `once` property ensures that animations are only triggered the first time a section comes into view and not each time the section exits and reenters the viewport, however, the opposite occurs on mobile. All animation seem to retrigger when the user reverses scroll direction. Can anyone help diagnose the issue? You can see it at this url, but only on a mobile device. Here is some of the css responsible for the animation:
.animate {
@for $i from 1 through 10 {
.singleLine:nth-child(#{$i}) .line {
animation: .5s ease-in-out fadeInUp forwards, .5s ease-in-out slideInBottom forwards;
animation-delay: 100ms + ($i * 50), 100ms + ($i * 75);
}
}
}
I don't think the CSS is the culprit, but I'm wondering if the animation fill mode (`forwards`) has anything to do with it?