简体   繁体   English

Angular2教程动画不适用于IE11

[英]Angular2 tutorial animations not working with IE11

I followed the Angular2 tutorial to setup a local development environment with the quick start seed [1], which worked well. 我遵循了Angular2教程,使用快速入门种子[1]设置了本地开发环境,效果很好。 Then I decided to test animations using a shortened version of the first example in [2]. 然后,我决定使用[2]中第一个示例的简化版本来测试动画。 The app.component.ts looks like this and it toggles the background color by clicking: app.component.ts如下所示,它通过单击以下内容来切换背景颜色:

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

@Component({
  selector: 'my-app',
  template: `<div [@heroState]="state" (click)="toggleState()">
                <h1>TourOfHeroes</h1>
            </div>
  `,
  animations: [
    trigger('heroState', [
      state('inactive', style({
        backgroundColor: '#eee'
      })),
      state('active',   style({
        backgroundColor: '#cfd8dc'
      })),
      transition('inactive => active', animate('1000ms ease-in')),
      transition('active => inactive', animate('1000ms ease-out'))
    ])
  ]
})

export class AppComponent {

  state = 'active';

  toggleState(){
    this.state = (this.state === 'active' ? 'inactive' : 'active');
  }
}

This works well in Chrome and Firefox, but not in IE11. 这在Chrome和Firefox中效果很好,但在IE11中效果不佳。 There is no transition is IE11, the background changes instantly (see [3]) IE11没有过渡,背景会立即更改(请参阅[3])

I did no project setup of my own and pretty much no coding either except for the inserted animation code. 我没有自己的项目设置,除了插入的动画代码外,几乎没有任何代码。 Is there any way to say why this doesn't work? 有什么办法说为什么这行不通吗?

Thank you! 谢谢!

[1]: github .com/angular/quickstart/archive/master.zip [1]:github .com / angular / quickstart / archive / master.zip

[2]: angular .io/docs/ts/latest/guide/animations.html [2]:角度.io / docs / ts / latest / guide / animations.html

[3]: i.imgur .com/WU3rvEW.gif [3]:i.imgur .com / WU3rvEW.gif

PS: Stackoverflow doesn't let me post more than two links, you have to copy them yourselves ... PS:Stackoverflow不允许我发布两个以上的链接,您必须自己复制它们...

Angular animations use web animations API and IE does not support it. 角度动画使用Web动画API,而IE不支持它。

http://caniuse.com/#feat=web-animation http://caniuse.com/#feat=web-animation

https://angular.io/docs/ts/latest/guide/animations.html https://angular.io/docs/ts/latest/guide/animations.html

You can add polyfill to get it working 您可以添加polyfill使其正常工作

https://github.com/web-animations/web-animations-js https://github.com/web-animations/web-animations-js

Try these steps to perform animation in IE11 : 尝试以下步骤在IE11中执行动画:

  1. Run npm install --save web-animations-js . 运行npm install --save web-animations-js

  2. Add import 'web-animations-js in polyfills.ts add it yourself; polyfills.ts添加polyfills.ts import 'web-animations-js自己添加;

Your animation will work in IE10+ , IE11 etc, browsers. 您的动画将在IE10 +IE11等浏览器中运行。

for more details refer below link --> https://angular.io/guide/browser-support 有关更多详细信息,请参见下面的链接-> https://angular.io/guide/browser-support

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM