feat(animations): expose the element value within transition events

This commit is contained in:
Matias Niemelä
2016-12-20 15:57:02 -08:00
parent 02dd90faed
commit 4bae4b3bb5
6 changed files with 113 additions and 37 deletions

View File

@ -5,20 +5,23 @@
* 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
*/
import {ElementRef} from '../linker/element_ref';
import {AnimationPlayer} from './animation_player';
import {AnimationTransitionEvent} from './animation_transition_event';
export class AnimationTransition {
constructor(
private _player: AnimationPlayer, private _fromState: string, private _toState: string,
private _totalTime: number) {}
private _player: AnimationPlayer, private _element: ElementRef, private _fromState: string,
private _toState: string, private _totalTime: number) {}
private _createEvent(phaseName: string): AnimationTransitionEvent {
return new AnimationTransitionEvent({
fromState: this._fromState,
toState: this._toState,
totalTime: this._totalTime,
phaseName: phaseName
phaseName: phaseName,
element: this._element
});
}

View File

@ -5,6 +5,7 @@
* 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
*/
import {ElementRef} from '../linker/element_ref';
/**
* An instance of this class is returned as an event parameter when an animation
@ -42,12 +43,19 @@ export class AnimationTransitionEvent {
public toState: string;
public totalTime: number;
public phaseName: string;
public element: ElementRef;
constructor({fromState, toState, totalTime, phaseName}:
{fromState: string, toState: string, totalTime: number, phaseName: string}) {
constructor({fromState, toState, totalTime, phaseName, element}: {
fromState: string,
toState: string,
totalTime: number,
phaseName: string,
element: any
}) {
this.fromState = fromState;
this.toState = toState;
this.totalTime = totalTime;
this.phaseName = phaseName;
this.element = new ElementRef(element);
}
}