Sanprieto Posted February 19, 2021 Share Posted February 19, 2021 Hello there, I have tried to change boolean (this.stop) value into the callback but It isn't work. I can get this using this: gsap.fromTo( cube.position,{ x: 150 }, { x: -150, duration:4, onComplete: this.finishGsap.bind(this), onCompleteParams: [ this.stop ] }) You can check into console this.stop value. But I can't access to the methods of the tween like ( this.time()) and other solution was pass 'this' like a parameter but I'm sure this isn't a good idea. I would like to use both into the callback. Anybody can help me? Thanks. See the Pen BaQZXoZ by sanprieto (@sanprieto) on CodePen Link to comment Share on other sites More sharing options...
ZachSaucier Posted February 19, 2021 Share Posted February 19, 2021 1 hour ago, Sanprieto said: other solution was pass 'this' like a parameter but I'm sure this isn't a good idea. Why is that? It seems like a good idea to me... 3 Link to comment Share on other sites More sharing options...
Solution Carl Posted February 19, 2021 Solution Share Posted February 19, 2021 Thanks for the demo. Please try setting callbackScope gsap.fromTo( cube.position,{ x: 150 }, { x: -150, duration:1, onComplete: this.finishGsap, onCompleteParams: [ this.stop ], callbackScope: this }) in the demo below the console logs true when the tween is done See the Pen LYbjYPB?editors=0010 by snorkltv (@snorkltv) on CodePen this video may help as well 4 Link to comment Share on other sites More sharing options...
Sanprieto Posted February 19, 2021 Author Share Posted February 19, 2021 Ok perfect ! I thought that there was an other way..., but pass "this" like parameter works perfect. Thanks. 1 Link to comment Share on other sites More sharing options...
ZachSaucier Posted February 19, 2021 Share Posted February 19, 2021 Note that you don't have to pass this.stop as a parameter if you're passing in the scope. 2 Link to comment Share on other sites More sharing options...
Sanprieto Posted February 19, 2021 Author Share Posted February 19, 2021 19 minutes ago, Carl said: Wow!!! I understand now. This video is really great and complete. Thank you so much and congratulations Carl ! 19 minutes ago, Carl said: this video may help as well 1 Link to comment Share on other sites More sharing options...
Carl Posted February 19, 2021 Share Posted February 19, 2021 Glad the video helped! You're welcome. 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