angular - Why is my :enter animation working but my :leave animation isn't? -


this works nicely bring new rows ngfor structure, :leave transition doesn't happen, or happens immediately. what's missing?

trigger('fadeinshrinkout', [     transition(':enter', [         style({             opacity: '0'         }),         animate('.5s ease-out', style({             opacity: '1'         })),     ]),     transition(':leave', [         style({             height: '*'         }),         animate('.5s ease-out', style({             height: '0'         }))     ]) ]) 

the animation applied in component template:

<my-component *ngfor="let row of rows">     <div [@fadeinshrinkout]="''"> ... </div> </my-component> 

i'm doing animation on element interior component because didn't work on component, animations in parent.

it's worth mentioning ngfor using observable. wonder if that's not factor, observable being recreated or else kills original array.

the answer is,

demo : https://plnkr.co/edit/iwnvfk0vfxaupoggmaan?p=preview

animations: [       trigger('fadeinshrinkout', [     transition(':enter', [     style({         opacity: '0',         height:'0'                       // added smoothness     }),     animate('.5s ease-out', style({         opacity: '1',         height: '*',                     // added smoothness     })), ]),     transition(':leave', [         style({             height: '*',             opacity: '1'                 // added         }),         animate('.5s ease-out', style({             height: '0',             opacity:'0'                  // added         }))     ])     ])   ], 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -