Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Lefthandmedia

how to do oncompleteAll for staggers

Recommended Posts

Hi,

I'm migrating some tweens from gsap2 to gsap3. i have a tween in my old code

    TweenMax.staggerTo(this.find('.level-1'), .5, {
      autoAlpha: 0, display: 'none', ease: Back.easeIn
    }, -0.03, allComplete, this);

allComplete is a function. How would i do the oncomplete all in GSAP3?

tnx

RDG

 

Share this post


Link to post
Share on other sites

Just use onComplete in the tween

 

gsap.to("#freds img", { y:100, ease:"none", stagger:0.5, onComplete:function() {
  console.log("done")
}
});

 

See the Pen LYGvdLm?editors=0011 by snorkltv (@snorkltv) on CodePen

 

 

Also be sure to learn about the stagger object

 

Staggering in GSAP3 is SUPER powerful

 

 

 

  • Like 5

Share this post


Link to post
Share on other sites
3 hours ago, ZachSaucier said:

See also the stagger docs :) 

Only when all other attempts have failed.

  • Like 1
  • Haha 1

Share this post


Link to post
Share on other sites

@Carl the onComplete fires after each tweened object. I only want when ALL of them are complete

@ZachSaucier there is no mention of onCompleteAll in the docs. and that is what i ended up using after a lot of trial and error

the solution was

 gsap.to(this.find('.level-1'), {
      duration: .5,
      autoAlpha: 0,
      display: 'none',
      ease: "back.easeIn",
      stagger: {
        each: -0.03,
        onCompleteAll: allComplete,
        onCompleteParams: this
      }
    })

i had the most trouble finding onCompleteParams. Probably worth mentioning in the docs

Share this post


Link to post
Share on other sites

Hi

 

there must be a misunderstanding here. 
I updated my demo so that it is incredibly clear that the onComplete ONLY fires once after all the staggers finish. You will see the images fade after all Freds move down.  Also the console.log only fires once. Please take another look. 
 

 

  • Like 3

Share this post


Link to post
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.

×