Jump to content


ScrollTrigger Lottie, create only when visible in viewport

Moderator Tag
Go to solution Solved by Rodrigo,

Recommended Posts


I'm currently working on a site with lots of heavy Lottie animation, I'm using THIS  linkup between ScrollTrigger and Lottie and it works perfectly. 

my only problem is that I want to create the Lottie DOM element only when visible in Viewport. I created this pen and as you can see on every progress update the animation start from the beginning and catches up. 

any advice?


Thanks in advance!

See the Pen yLjeQLV by amir-trujillo (@amir-trujillo) on CodePen

Link to comment
Share on other sites

  • Solution



The issue is that your callback to update the lottie instance always starts at the first frame:

function moveLottieOnScroll(animation, vars, self) {
  if (animation === undefined) {
  timeObj = { currentFrame: 0 }; // <- Always starts at the first frame

Just removing that from the code seems to work in the way you intend:

See the Pen WNJywLp by GreenSock (@GreenSock) on CodePen


Happy Tweening!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.