代码之家  ›  专栏  ›  技术社区  ›  cup_of

在子对象上设置父对象宽度的动画*ngIf | angular

  •  0
  • cup_of  · 技术社区  · 5 年前

    我想在子组件出现/消失时设置父容器宽度的动画 *ngIf

    我知道如何让孩子在电脑上动画片 ,我已经设置好了:

    animations: [loadingEnter]
    
    loadingEnter = trigger('loadingEnter', [
      transition(':enter', [
        style({ opacity: 0 }),
        animate('300ms', style({ opacity: 1 })),
      ]),
    ]);
    
    <div class="parent">
      <div *ngIf="myCondition"></div>
      <div *ngIf="!myCondition"></div>
    </div>
    

    孩子能正常地活动,但我希望当孩子出现/消失时,父母能平稳地成长。

    孩子有动态宽度,所以我不能设置父宽度和过渡css的宽度。

    有什么想法吗?

    0 回复  |  直到 4 年前