feat(animations): make sure animation callback reports the totalTime (#11022)

Closes #11022
This commit is contained in:
Matias Niemelä
2016-08-24 16:55:00 -07:00
committed by Victor Berchet
parent 8b782818f5
commit 4f8f8cfc66
6 changed files with 145 additions and 36 deletions

View File

@ -0,0 +1,51 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* An instance of this class is returned as an event parameter when an animation
* callback is captured for an animation either during the start or done phase.
*
* ```typescript
* @Component({
* host: {
* '[@myAnimationTrigger]': 'someExpression',
* '(@myAnimationTrigger.start)': 'captureStartEvent($event)',
* '(@myAnimationTrigger.done)': 'captureDoneEvent($event)',
* },
* animations: [
* trigger("myAnimationTrigger", [
* // ...
* ])
* ]
* })
* class MyComponent {
* someExpression: any = false;
* captureStartEvent(event: AnimationTransitionEvent) {
* // the toState, fromState and totalTime data is accessible from the event variable
* }
*
* captureDoneEvent(event: AnimationTransitionEvent) {
* // the toState, fromState and totalTime data is accessible from the event variable
* }
* }
* ```
*
* @experimental Animation support is experimental.
*/
export class AnimationTransitionEvent {
public fromState: string;
public toState: string;
public totalTime: number;
constructor({fromState, toState,
totalTime}: {fromState: string, toState: string, totalTime: number}) {
this.fromState = fromState;
this.toState = toState;
this.totalTime = totalTime;
}
}