angular-animations icon indicating copy to clipboard operation
angular-animations copied to clipboard

Animation callbacks get called even tho they didnt run

Open MickL opened this issue 2 years ago • 1 comments

When having a leave animation the start and end animation

Template: <div *ngIf="isVisible" [@fadeOutOnLeave] (@fadeOutOnLeave.done)="animDone($event)"></div>

Component:

//...

isVisible = false;

ngOnInit() {
  setTimeout(() => { this.isVisble = true; }, 5000);
  setTimeout(() => { this.isVisble = false; }, 10000);
}

animDone(event: AnimationEvent) {
  console.log('Animation Ended', event);
}

I would assume that animDone() does only gets called after the div has been faded-out. Instead animDone gets called on init already:

fromState: "void"
phaseName: "done"
toState: null
totalTime: 0

MickL avatar Mar 03 '23 22:03 MickL

Still the same issue unfortunately, is this project still maintained?

Workaround:

animDone(event: AnimationEvent) {
   if (event.toState === 'void') {
      console.log('Animation Ended', event);
   }
}

MickL avatar Oct 22 '23 14:10 MickL