Jump to content
BradLee

capture element(s) being tweened in onComplete

Recommended Posts

Is there a way to capture the element(s) being tweened within the onComplete param?

 

 

For example, I'm trying to replace the code: 'element I'm tweening here' with the actual element that is being tweened.

let div = document.querySelector(`div`);
TweenLite.to(div, 2, {x:100, onComplete: () => console.log(`element I'm tweening here`)});

See the Pen qZgxqo?editors=0010 by BradLee (@BradLee) on CodePen

Share this post


Link to post
Share on other sites

Just a little FYI about callback scope. Arrow functions aren't scoped, but if you use a regular function you can just use 'this' to reference the tween.

TweenLite.to(div, 2, { x: 100, onComplete: function() { console.log(this.target); }})
  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.