Jump to content
Search Community

ScrollTrigger with Lottie Animation and MatchMedia

Peter Moore test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

I'm using GSAP MatchMedia to load Lottie animations tied to scroll position (using ScrollTrigger). There's one Lottie animation for portrait orientation and another for landscape orientation. MatchMedia is working on page load, showing the correct animation depending on screen orientation, but try as I might I cannot get it to work when the orientation changes. 

 

How do I essentially reset everything when the page orientation changes and load in place the correct animation?

 

Hopefully my codepen makes more sense than this post!

 

Many thanks in advance! 

See the Pen abjJowV by lejazz (@lejazz) on CodePen

Link to comment
Share on other sites

  • Solution

Thanks for providing such a nice minimal demo, @Peter Moore! I wish all community members were as thoughtful. 

 

I just updated the LottieScrollTrigger() function to be context-aware so that it kills the animation/ScrollTrigger when the MatchMedia context gets reverted, so all you should need to do is update that one function: 

See the Pen VwBpepP?editors=0010 by GreenSock (@GreenSock) on CodePen

 

Does that work the way you expected? 

  • Like 1
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.
×
×
  • Create New...