fix(animations): properly cleanup query artificats when animation construction fails
This commit is contained in:

committed by
Jason Aden

parent
71ee0c5b03
commit
858dea98e5
@ -29,12 +29,16 @@ export class AnimationTransitionFactory {
|
||||
build(
|
||||
driver: AnimationDriver, element: any, currentState: any, nextState: any,
|
||||
options?: AnimationOptions,
|
||||
subInstructions?: ElementInstructionMap): AnimationTransitionInstruction|undefined {
|
||||
subInstructions?: ElementInstructionMap): AnimationTransitionInstruction {
|
||||
const animationOptions = mergeAnimationOptions(this.ast.options || {}, options || {});
|
||||
|
||||
const backupStateStyles = this._stateStyles['*'] || {};
|
||||
const currentStateStyles = this._stateStyles[currentState] || backupStateStyles;
|
||||
const nextStateStyles = this._stateStyles[nextState] || backupStateStyles;
|
||||
const queriedElements = new Set<any>();
|
||||
const preStyleMap = new Map<any, {[prop: string]: boolean}>();
|
||||
const postStyleMap = new Map<any, {[prop: string]: boolean}>();
|
||||
const isRemoval = nextState === 'void';
|
||||
|
||||
const errors: any[] = [];
|
||||
const timelines = buildAnimationTimelines(
|
||||
@ -42,13 +46,11 @@ export class AnimationTransitionFactory {
|
||||
subInstructions, errors);
|
||||
|
||||
if (errors.length) {
|
||||
const errorMessage = `animation building failed:\n${errors.join("\n")}`;
|
||||
throw new Error(errorMessage);
|
||||
return createTransitionInstruction(
|
||||
element, this._triggerName, currentState, nextState, isRemoval, currentStateStyles,
|
||||
nextStateStyles, [], [], preStyleMap, postStyleMap, errors);
|
||||
}
|
||||
|
||||
const preStyleMap = new Map<any, {[prop: string]: boolean}>();
|
||||
const postStyleMap = new Map<any, {[prop: string]: boolean}>();
|
||||
const queriedElements = new Set<any>();
|
||||
timelines.forEach(tl => {
|
||||
const elm = tl.element;
|
||||
const preProps = getOrSetAsInMap(preStyleMap, elm, {});
|
||||
@ -64,9 +66,8 @@ export class AnimationTransitionFactory {
|
||||
|
||||
const queriedElementsList = iteratorToArray(queriedElements.values());
|
||||
return createTransitionInstruction(
|
||||
element, this._triggerName, currentState, nextState, nextState === 'void',
|
||||
currentStateStyles, nextStateStyles, timelines, queriedElementsList, preStyleMap,
|
||||
postStyleMap);
|
||||
element, this._triggerName, currentState, nextState, isRemoval, currentStateStyles,
|
||||
nextStateStyles, timelines, queriedElementsList, preStyleMap, postStyleMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ export interface AnimationTransitionInstruction extends AnimationEngineInstructi
|
||||
queriedElements: any[];
|
||||
preStyleProps: Map<any, {[prop: string]: boolean}>;
|
||||
postStyleProps: Map<any, {[prop: string]: boolean}>;
|
||||
errors?: any[];
|
||||
}
|
||||
|
||||
export function createTransitionInstruction(
|
||||
@ -28,7 +29,8 @@ export function createTransitionInstruction(
|
||||
isRemovalTransition: boolean, fromStyles: ɵStyleData, toStyles: ɵStyleData,
|
||||
timelines: AnimationTimelineInstruction[], queriedElements: any[],
|
||||
preStyleProps: Map<any, {[prop: string]: boolean}>,
|
||||
postStyleProps: Map<any, {[prop: string]: boolean}>): AnimationTransitionInstruction {
|
||||
postStyleProps: Map<any, {[prop: string]: boolean}>,
|
||||
errors?: any[]): AnimationTransitionInstruction {
|
||||
return {
|
||||
type: AnimationTransitionInstructionType.TransitionAnimation,
|
||||
element,
|
||||
@ -41,6 +43,7 @@ export function createTransitionInstruction(
|
||||
timelines,
|
||||
queriedElements,
|
||||
preStyleProps,
|
||||
postStyleProps
|
||||
postStyleProps,
|
||||
errors
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user