Jump to content

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

Access stagger element/index possible?

Recommended Posts

Is this possible to access animated element node or at least some index of stagger in onComplete? I see no data in fucntion


this.tl.staggerFromTo('#hello > path', 2, {
  drawSVG: '50% 50%'
}, {
  drawSVG: '100%',
  onComplete: (i) => {
    console.log('DONE', i) // undefined
}, 1)


For example, I want to add fill when stagger of particular element is complete. Or other stuff...

Link to comment
Share on other sites

You can get the element in the callback using this.target. Note that arrow functions aren't scoped, so you would need to use a regular function.


// BAD
onComplete: () => {

onComplete: function() {



See the Pen EGxZVx by osublake (@osublake) on CodePen




If you need the index, you can create the stagger in a loop. That's all GSAP is doing. 


See the Pen VqwPem by osublake (@osublake) on CodePen



  • Like 5
Link to comment
Share on other sites

Hi @therddlr,


A CodePen, which clarifies your structure, would be - as always - very helpful.

If every staggered object is affected, then cycle (used in a second tween, positioned as you want) offers itself:


See the Pen roNjag by mikeK (@mikeK) on CodePen


Best regards




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