Jump to content
Search Community

Staggering li's and their bullet points.

JPM82 test
Moderator Tag

Recommended Posts

I'm using GSAP to animate in some li's and their bullet point counterparts (using the CSSRule plugin).  I'd like each bullet point to animate in directly after the li, and for the rest to do that same.  Basically, the next li will start to come in just as the previous li's bullet point has finished.  Currently, however, the li's come in and then the bullet points come in when the li's have completed.  Anyone know I can achieve this???

See the Pen gOXjbXa by Gemini7401 (@Gemini7401) on CodePen

Link to comment
Share on other sites

There are a few ways to do this, but I think for control sake, you can run an onComplete callback inside your li stagger to tween the after element, so it'd look something like this:

gsap.to(".service-styles--list li", {
  x: 0,
  opacity: 1,
  duration: 1.5,
  stagger: {
    each: .5,
    onComplete: function(){
      gsap.to(this.targets()[0], {'--bullet-opacity': 1, '--bullet-translate': 0})
    }
  },
})

It'll be more performant to animate a CSS custom property that's applied to the after element, than it will be to animate the ::after element directly with the CSSRulePlugin.

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