我試圖動畫點擊不只是動畫其餘如何觸發動畫特定項目,而不是所有的項目列表中的
@Component({
selector: \\\\\
templateUrl: \\\\
animations: [
trigger('showFull', [
state('shrink', style({
height: '50px'
})),
state('expand', style ({
height: '*'
})),
transition('shrink <=> expand', animate('300ms ease-in'))
])
]
})
///
export class myComp {
state: string = 'shrink';
}
toggleExpansion(){
this.state = (this.state === 'shrink' ? 'expand' : 'shrink');
}
的.html:
<div *ngFor="let item of items">
<ion-item [@showFull]="state" (click)="toggleExpansion()">
{{item.description}}
</ion-item>
</div>
如何/什麼傳遞給函數,以便state
不會更改所有列出的項目。
在一個側面的問題,如何提高動畫代碼摺疊和展開
上面是當狀態爲expand
,這時候狀態shrink
它可以注意到,該段的開始也崩潰/覆蓋...如何動畫擴展和崩潰從&到一個特定的點!
你需要有狀態列表中的每個項目。 –
這是什麼理想的解決方案,因爲我的項目列表是從服務器端和長度將是未知的,也用戶將添加和刪除這些項目..我這樣做截斷和顯示段落 – Yasir
你可以添加一個屬性'狀態',當你從服務器端獲得對象時。 –