代码之家  ›  专栏  ›  技术社区  ›  Aaron Ullal

具有状态的nativescript角度动画从不工作

  •  1
  • Aaron Ullal  · 技术社区  · 7 年前

    我正在尝试让动画在ng nativescript应用程序中工作。

    animations: [
        trigger('accessState', [
          state('loggingIn', style({ "color" : "red" })),
          state('signingUp', style({ "color" : "blue" })),
          transition('loggingIn <=> signingUp', [animate('600ms ease-out')])
        ])
      ]
    

    简单明了:两种状态和正义 color 转换期间的属性更改。 在xml中,我使用以下动画:

    <Label text="hey there buddy" [@accessState]="isLoggingIn ? 'loggingIn' : 'signingUp' "></Label>
    

    isLoggingIn 但是,标签始终保持绿色(因为css表中定义了一种样式),并且似乎从未调用触发器。我错过什么了吗?

    2 回复  |  直到 7 年前
        1
  •  3
  •   Aaron Ullal    7 年前

    Nativescript动画模块必须导入并包含在模块中。

    import { NativeScriptAnimationsModule } from "nativescript-angular/animations"
    

    这会成功的。

        2
  •  0
  •   Vega Stipe    7 年前

    我还没有测试,但应该可以:

       <label text="hey there buddy" [@accessState]="isLoggingIn"></label>
       <button (click)="changeState('loggingIn')">log up</button>
       <button (click)="changeState('signingUp')">sign up</button>
    

    ...
    isLoggingIn="reset";
    ....
    changeState(state){
       this.isLoggingIn="reset";
       setTimeout(() => { this.isLoggingIn = state;},300);
    }