编程语言
首页 > 编程语言> > javascript – Angular 4 – 如何从Directive中运行动画?

javascript – Angular 4 – 如何从Directive中运行动画?

作者:互联网

我在repo here上有一个悬而未决的问题,但我认为无论如何都要在这里提问.

我想以编程方式从指令中触发动画.使用Renderer.animate时,我得到:

Renderer.animate is no longer supported!

使用Renderer.invokeElementMethod时,我得到:

Cannot read property 'apply' of undefined

我该怎么做?

解决方法:

变化即将来临Angular!请参阅官方Angular回购中的this GitHub issue.

TL; DR

What’s really good: With the first beta of angular 4.1 (which comes out as the follow-up release to this weeks 4.0.0) you can do the following:

class MyCmp {


constructor(private _builder: AnimationBuilder) {
   }
   myMethod() {
      const animation = this._builder.build([
        style(...),
        animate(...),
        group([
          animate(...)
          animate(...)
          animate(...)
        ])
      ]);
      const player = animation.create(someElement);
      player.play();
   }
}

标签:javascript,typescript,angular,angular4
来源: https://codeday.me/bug/20190622/1265688.html