e11 Posted December 1, 2019 Share Posted December 1, 2019 The "this" was dropped in 3.0 .call( callback:Function, params:Array, position:* ) : self vs .call( callback:Function, params:Array, scope:*, position:* ) : * scope: * (default = null) — The scope in which the callback should be called (basically, what “this” refers to in the function). NOTE: this parameter only exists in the JavaScript and AS2 versions. How do I port this code to GSAP3? Here are the contents of a class method timelineMax .add([tmTitleSet, tmMetricSet, tmFooterSet]) .add([tmTitle]) .add([tmMetric, tmFooter]) .play() .call(this.animationDone, null, this, "+=1"); Link to comment Share on other sites More sharing options...
OSUblake Posted December 1, 2019 Share Posted December 1, 2019 Don't know why that was dropped. Just use bind. You can even include params. gsap.timeline() .add(this.animationDone.bind(this), "+=1"); // with params gsap.timeline() .add(this.animationDone.bind(this, "foo", "bar"), "+=1"); From the code you posted, it looks like you could also do this. gsap.timeline({ onComplete: this.animationDone, callbackScope: this }) .add([tmTitleSet, tmMetricSet, tmFooterSet]) .add([tmTitle]) .add([tmMetric, tmFooter]) .set({}, {}, "+=1"); And I'm guessing that the play() call in there is unnecessary. Animations don't start playing until the next cycle. 2 Link to comment Share on other sites More sharing options...
e11 Posted December 2, 2019 Author Share Posted December 2, 2019 @OSUblake, Thank you - bind() works perfectly. The code with "Set" is generative and variable names need work. gsap.timeline() .add(this.animationDone.bind(this, "foo", "bar"), "+=1"); 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