I have an angular 7 project and imported Gsap library. I want an animation to be played every time I navigate to a page so I've implemented the gsap animation inside ngOnInit, but the animation plays only for the first time I visit the page and in the next visits there is no animation. I've created a callback to log a message when the animation completes and every time I navigate to the page I can see the complete message is logged in the console but there is no animation. here is my ts code:
import { Component, OnInit } from "@angular/core";
import { TweenMax } from "gsap";
@Component({
selector: "app-list",
templateUrl: "list.page.html",
styleUrls: ["list.page.scss"]
})
export class ListPage implements OnInit {
ngOnInit() {
TweenMax.to("#myTarget", 1, {
y: -50,
onComplete: function() {
console.log("animation completed");
}
});
}
}
thanks for help!