【问题标题】:Angular routing animations play sporadically on mobile Chrome角度路由动画在移动 Chrome 上偶尔播放
【发布时间】:2016-12-28 18:57:07
【问题描述】:

我为我的应用程序的所有页面设置了路由动画,也就是说,每个可以路由到的组件都有

@Component({
    selector: '...',
    templateUrl: '...',
    styleUrls: ['...'],
    animations: [
        trigger('flyInOut', [
            state('in', style({ opacity: 1, transform: 'translateX(0)' })),
            transition('void => *', [
                style({
                    opacity: 0,
                    transform: 'translateX(-100%)'
                }),
                animate('0.3s ease-in')
            ]),
            transition('* => void', [
                animate('0.3s 10 ease-out', style({
                    opacity: 0,
                    transform: 'translateX(100%)'
                }))
            ])
        ])
    ]
})

在他们的.ts 文件中和

<section [@flyInOut]="active">
   ...
</section>

在其模板中。所以理论上,每一页都应该从屏幕的左侧飞入并从右侧退出。这在桌面 Chrome 上完美运行,没有例外。

但是,在我运行移动 Chrome 55.0.2883.91(桌面:.87)的平板电脑上,动画只在某些视图上播放,而且似乎只在第一次访问该页面时播放。我在这里缺少移动浏览器的内容吗?

顺便说一下,这是 Angular 4.0.0-beta.1。

【问题讨论】:

  • 我知道这有点晚了 - 但你有解决办法吗?

标签: angular angular2-routing angular2-animation


【解决方案1】:

它必须有效。不知道具体原因。不确定,但您可以尝试以下操作(不做任何更改,只是给您提供其他方法)。

animations: [
        trigger('flyInOut', [

             <!--- not required at all ----------->
               state('in', style({ opacity: 1, transform: 'translateX(0)' })),
             <!--- not required at all ----------->

            transition(':enter', [       //<<---changed line but same thing.
                style({
                    opacity: 0,          //<<---not sure with opacity. if view doesn't come up, change it to 1
                    transform: 'translateX(-100%)'
                }),
                animate('0.3s ease-in')
            ]),
            transition(':leave', [       //<<---changed line but same thing.
                animate('0.3s 10 ease-out', style({
                    opacity: 0,
                    transform: 'translateX(100%)'
                }))
            ])
        ])
    ]


<section [@flyInOut]>   //<<----if you are not using active state/variable anywhere then remove it
   ...
</section>

【讨论】:

  • 感谢您的提示!不幸的是,行为保持不变。只有一个组件的动画在移动设备上始终如一地工作,我们将研究该页面的不同之处。
猜你喜欢
  • 2019-01-16
  • 2019-10-02
  • 2021-05-17
  • 2013-09-30
  • 2019-12-22
  • 2023-03-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多