StormCode Posted February 26, 2020 Share Posted February 26, 2020 Hi There, I'm wondering if it is possible to get the following to work with Typescript/Angular: animateIn(ani) { // only do stuff if requested animation is different than active slide if (ani !== this.currentAnimation) { this.currentAnimation.reverse().timeScale(5); // faster speed // this.currentAnimation.vars.callbackScope = this; this.currentAnimation.eventCallback('onReverseComplete', this.playNext); this.nextAnimation = ani; } } playNext() { this.nextAnimation.play().timeScale(1); this.currentAnimation = this.nextAnimation; } It seems playNext() doesn't fire after "onReverseComplete" I have a simple StackBlitz https://stackblitz.com/edit/angular-csxrtd Thanks a lot for any help. See the Pen by edit (@edit) on CodePen Link to comment Share on other sites More sharing options...
ZachSaucier Posted February 26, 2020 Share Posted February 26, 2020 Hey StormCode and welcome. I don't quite understand your logic. You want animation 1 to play on init and then allow the buttons to reverse the running animation and play the animation for the button clicked on, right? I'd set it up like this: https://stackblitz.com/edit/angular-ztcmvh?file=src/app/app.component.ts I think (other than a logical error where things weren't playing in your latest edit) the key difference is that I change the timeScale before .reverse()ing the animation. This is because if you do .reverse().timeScale(positiveNumber) then it will play forwards. Alternatively, you could just use a negative timeScale (granted you're using GSAP 3) - no need to even call .reverse() 1 Link to comment Share on other sites More sharing options...
StormCode Posted February 26, 2020 Author Share Posted February 26, 2020 You sir, are a genius! and I see the light. I based my "logic" on this See the Pen yJLyxM by GreenSock (@GreenSock) on CodePen Seriously Zach... Thanks a lot mate. 2 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