Angular 4个动画到高度*

Angular 4 animation to height *

我对 Angular 中的动画模块中的某个错误感到困惑 4. 使用 Angular 2.x 中的动画,我制作了一个动画从高度 * 到固定高度的动画。这在 Angular 2 中工作得很好。另一方面,当使用 Angular 4 时,在动画完成之前重新触发动画时,应用了动画的元素的高度会出现错误。通配符 (*) 高度似乎是导致问题的原因。这是一个可以重现该问题的演示片段。当元素处于 *-height 状态时双击该元素会触发该错误:

import { Component } from '@angular/core';
import { trigger, animate, state, transition, style } from '@angular/animations';

@Component({
  selector: 'app-root',
  template: `
  <h1 [@toggleAnimation]="isEnabled" (click)="isEnabled = isEnabled === 'active' ? 'inactive' : 'active'" style="background: blue">
    {{title}}
  </h1>`,
  animations:
  [
    trigger('toggleAnimation', [
      state('active', style({
        height: '*',
      })),
      state('inactive', style({
        height: '600px',
      })),
      transition('active <=> inactive', animate('500ms ease-in-out'))
    ])
  ]
})
export class AppComponent {
  title = 'app works!';
  isEnabled = 'inactive';
}

我使用通配符值设置高度动画的方式有问题吗,或者实际上通配符高度的行为方式有问题吗?

似乎是一个错误:https://github.com/angular/angular/issues/15507

显然 !4.2.0-rc.1 中的一个 'secret' 值,它似乎解决了这个问题,但这似乎不是官方支持或将在正式发布。

https://plnkr.co/edit/pZamSqPX9Vb4J6JL721u?p=preview 显示它在 4.2.0-rc.1! 中工作,然后转到 config.js 并更改为 4.0.0 并更改 ! 回到 * 看看它又是怎么出问题的。