Jump to content


Creating a Carousel

Moderator Tag

Recommended Posts

The carousel switches the images properly but there seems to be a jank in the animation when it restarts. Opening dev tools, it shows that the opacity changes from 0 to 1 immediately instead of transitioning like the others.

See the Pen LYGJNdY by ebinabo (@ebinabo) on CodePen

Link to comment
Share on other sites

Hey ebinabo. The main issue here is that you are trying to animate the original image from an opacity of 1 to opacity of 1, so naturally it you can't perceive the animation (because the value is always the same).


In general you should avoid using onCompletes to reset variables in your animations. It's a whole lot cleaner to create animations beforehand and just let them do their thing, controlling them with control methods as necessary. In fact, not doing so is one of the most common GSAP mistakes.


I might set it up along the lines of this:

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

  • Like 5
Link to comment
Share on other sites

@ZachSaucier thank you so much. I just learnt that you could tl.add(anotherTl) lol and that's so cool! Now I'm gonna take it to the next level!

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