Share Posted March 31, 2016 Hi! I'm new to GSAP (and loving it!) and I'm trying to figure out how to pass a reference to the DOM element I'm tweening to the onComplete function. I've tried the following: TweenLite.to($("#content li")[i], 1, {top:"150%", onCompleteParams:[lmnt], onComplete:function(){ console.log(lmnt); //Uncaught ReferenceError: lmnt is not defined }}); TweenLite.to($("#content li")[i], 1, {top:"150%", onCompleteParams:["lmnt"], onComplete:function(){ console.log(lmnt); //Uncaught ReferenceError: lmnt is not defined }}); TweenLite.to($("#content li")[i], 1, {top:"150%", onComplete:function(){ console.log(this); //appears to be TweenLite object--instanceof HTMLElement is false }}); TweenLite.to($("#content li")[i], 1, {top:"150%", onCompleteScope:this, onComplete:function(){ console.log(this.toString()); //[object Window] }}); How can I pass reference the DOM element that just finished tweening? I'm trying to reset the top parameter to it's starting value so the next time it tweens it will be starting from the beginning instead of the end. Halp? Thanks! Link to comment Share on other sites More sharing options...
Share Posted March 31, 2016 Hi dwillis pls try : this.target 6 Link to comment Share on other sites More sharing options...
Author Share Posted March 31, 2016 Hi Diaco! Thanks for the quick response! I tried this: TweenLite.to($("#content li")[i], 1, {top:"150%", onCompleteScope:this.target, onComplete:function(){ console.log(this); //appears to be TweenLite object }}); It seems like this gives me the same result as leaving off the onCompleteParams and onCompleteScope parameters all together. Link to comment Share on other sites More sharing options...
Author Share Posted March 31, 2016 I've just realized that it works when I use this.target in my actual callback, which must be what you meant. Thank you! Link to comment Share on other sites More sharing options...
Share Posted March 31, 2016 Hi, What Diaco meant was this: TweenLite.to($("#content li")[i], 1, {top:"150%", onComplete:function(){ console.log(this.target); }}); 6 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now