我正在研究可摺疊組件,其中一個可以通過單擊來上/下顯示/隱藏詳細信息。該組件如下:Angular2動畫:: Easings無法按預期方式工作
// component.ts
import {Component, Directive, Input} from '@angular/core';
import {trigger, state, style, transition, animate} from '@angular/core'
@Component({
selector: 'expandable',
template: '<div *ngIf="isExpanded" @animate="'slide'"><ng-content></ng-content></div>',
animations: [
trigger('animate', [
state('slide', style({ overflow: 'hidden', height: '*' })),
transition('slide => void', [animate('200ms ease-out', style({ height: 0 }))]),
transition('void => slide', [style({ height: 0 }), animate('200ms ease-out', style({ height: '*' }))])
])
]
})
export class SimExpandable {
private _expanded: boolean = false;
@Input('expanded') set expanded(value: string | boolean) {
this._expanded = (value === 'true' || value === true);
}
get isExpanded(): boolean { return this._expanded }
}
該組件工作正常,部分。但是,動畫並不完美。我已經將組件配置爲使用動畫ease-out
,但實際上,組件呈線性動畫。
我使用ease-out
,easeOut
,ease-out-cubic
,easeOutCubic
,ease-in-out
,easeInOut
,bounce
,和許多其他的排列,但組件仍動畫線性嘗試。我真的需要使用ease-out
爲我的組件。任何幫助將非常感激。
您是否添加了[web-animations.js polyfill](https://github.com/web-animations/web-animations-js)? – PierreDuc
該angular2文檔狀態,你不需要將其添加到常見的瀏覽器..即時通訊使用鉻進行測試..但我可以明確地添加它.. – AweSIM
沒有運氣,或者.. =( – AweSIM