fix(animations): properly handle cancelled animation style application

This commit is contained in:
Matias Niemelä
2017-06-29 17:05:52 -07:00
committed by Jason Aden
parent 858dea98e5
commit 105e920b69
7 changed files with 194 additions and 74 deletions

View File

@ -9,7 +9,7 @@ import {AUTO_STYLE, AnimationPlayer, NoopAnimationPlayer, ɵStyleData} from '@an
import {AnimationDriver} from '../../src/render/animation_driver';
import {containsElement, invokeQuery, matchesElement} from '../../src/render/shared';
import {allowPreviousPlayerStylesMerge} from '../../src/util';
/**
* @experimental Animation support is experimental.
@ -56,12 +56,15 @@ export class MockAnimationPlayer extends NoopAnimationPlayer {
public duration: number, public delay: number, public easing: string,
public previousPlayers: any[]) {
super();
previousPlayers.forEach(player => {
if (player instanceof MockAnimationPlayer) {
const styles = player.currentSnapshot;
Object.keys(styles).forEach(prop => this.previousStyles[prop] = styles[prop]);
}
});
if (allowPreviousPlayerStylesMerge(duration, delay)) {
previousPlayers.forEach(player => {
if (player instanceof MockAnimationPlayer) {
const styles = player.currentSnapshot;
Object.keys(styles).forEach(prop => this.previousStyles[prop] = styles[prop]);
}
});
}
this.totalTime = delay + duration;
}