Jump to content
Search Community

ScrollTrigger reverse animation using fromTo

Aamir Mansuri test
Moderator Tag

Recommended Posts

Hey Aamir. Several things:

  • You don't need ScrollMagic or CSSRulePlugin so I removed them. In general we recommend animating CSS variables instead of using the CSSRulePlugin so long as it has the browser support that you need.
  • We recommend using the GSAP 3 syntax, not the old syntax like you're using. See the migration guide for more info:
  • You misspelled toggleActions. You also had the wrong order for the effect that you're wanting. This is your main issue. Your toggleActions should be:
    toggleActions: "restart none none reverse"

     

  • Your tween and ScrollTrigger affecting your progress element should not be repeated for every single image reveal. Put it outside of the .each() loop.

  • You create a timeline but don't actually use it. I'd use it and use a singular ScrollTrigger for each image reveal. You can use the position parameter to place things where you want them in the timeline.
  • You have a stagger applied to the projectInfo tween but each element only has one element with that class so the stagger does nothing. So I removed it.
  • I'd personally avoid using jQuery but I left it in there.
  • I'd personally use ES6 formatting (like const, let, etc.) and transpile it but I didn't do that in your project either.

Making the above changes, you should get something like this:

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

 

I highly recommend you thoroughly go through all of the links in my signature below. Doing so will save you a lot of time in the long run!

  • Like 4
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...