Posting here for visibility. If you're using the <lottie-player> component and loading the Lottie animation in through it's src and having a flickering issue on iOS while tying this to a scrub for GSAP, the problem is that the lottie player only loads in the first png in the sequence until scrubbing begins and then dynamically introduces the frames for every scroll jack.
So in my instance the setup kind of looked like:
<lottie-player
mode="normal"
src="/your-lottie.json"
style="width: 100%"
>
</lottie-player>
let player = document.querySelector('lottie-player')
let animation = player.getLottie()
let playhead = { frame: 0 }
let tl = gsap.timeline({
defaults: { duration: 1 }
})
tl.to(playhead, {
frame: (Whatever frame you want the animation to scrub to) || animation.totalFrames,
duration: (however long you want it to take) || animation.totalFrames,
ease: 'none',
onUpdate: () => animation.goToAndStop(playhead.frame, true)
})
// add in whatever other timeline actions you need to do after this, and continue chaining
ScrollTrigger.create({
trigger: selector,
pin: true,
start: 'top top',
animation: tl,
scrub: 1
})
I was having trouble figuring out how to use the LottieScrollTrigger in a timeline the way I needed to so I had to use the regular scroll trigger. Essentially I wanted to pin the element when I got there, scrub through a bit of the lottie animation at a predetermined point, show something else, scrub to another predetermined point, show another thing, then finish the animation. So here we're using the playhead variable with a frame property and on update from the scrub we're making the animation go to that point from the playhead.
This worked well in all browsers other than iOS, it was flickering and that was because all frames were not loaded initially and being loaded at the instant scrolling occurred. Instead you'll want to load the lottie animation in with JS
player = lottie.loadAnimation({
container: lottieElement, // element you're injecting the lottie into
renderer: 'svg',
loop: false,
autoplay: false,
path: lottiePath // the path to the animation json
});
player.addEventListener('data_ready', () => {
// do all your GSAP stuff after the data is loaded
})
This will load the entire animation and stop the flickering