Jump to content
GreenSock

robbue

staggerTo onComplete param

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

When a staggerTo is complete for a object, I want to do something with that object.

 

Something like this:

onComplete: function(obj) {
      obj.removeClass('blue');
}

This works, but I'm removing the class on every box on every complete. I only want to remove the class on the object that finished:

See the Pen 178473f51886095f8541a1ce37f446ee by robbue (@robbue) on CodePen

 

This does the trick, but is it possible to do it with staggerTo?

See the Pen 43750f400ad119d1fa107843900c736e by robbue (@robbue) on CodePen

Link to comment
Share on other sites

Hi,

 

You could try passing the tween to the onComplete call and use the tween's target, like this:

var blink = new TimelineMax({repeat: -1, yoyo: true});

blink.staggerTo(".box", 0.1,
{
  className: "+=blue",
  ease:Linear.easeNone,
  onCompleteParams: ["{self}"], 
  onComplete: function(tween)
  {
    $(tween.target).removeClass('blue');
  }
}, 0.1);

Although you could achieve the same effect with a TweenMax.staggerTo() instance, unless you're adding something else to the timeline.

 

Best,

Rodrigo.

  • Like 3
Link to comment
Share on other sites

Perfecto!

 

This is what I was looking for:

onCompleteParams: ["{self}"], 
  • 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.
×