fix(animations): ensure parent animations are triggered before children (#11201)

This commit is contained in:
Matias Niemelä
2016-09-01 23:24:26 +03:00
committed by Martin Probst
parent e42a057048
commit c9e5b599e4
7 changed files with 135 additions and 21 deletions

View File

@ -37,6 +37,7 @@ export class CompileView implements NameResolver {
public classStatements: o.Statement[] = [];
public createMethod: CompileMethod;
public animationBindingsMethod: CompileMethod;
public injectorGetMethod: CompileMethod;
public updateContentQueriesMethod: CompileMethod;
public dirtyParentQueriesMethod: CompileMethod;
@ -74,6 +75,7 @@ export class CompileView implements NameResolver {
public animations: CompiledAnimationTriggerResult[], public viewIndex: number,
public declarationElement: CompileElement, public templateVariableBindings: string[][]) {
this.createMethod = new CompileMethod(this);
this.animationBindingsMethod = new CompileMethod(this);
this.injectorGetMethod = new CompileMethod(this);
this.updateContentQueriesMethod = new CompileMethod(this);
this.dirtyParentQueriesMethod = new CompileMethod(this);

View File

@ -105,6 +105,7 @@ function bindAndWriteToRenderer(
var oldRenderValue: o.Expression = sanitizedValue(boundProp, fieldExpr);
var renderValue: o.Expression = sanitizedValue(boundProp, currValExpr);
var updateStmts: any[] /** TODO #9100 */ = [];
var compileMethod = view.detectChangesRenderPropertiesMethod;
switch (boundProp.type) {
case PropertyBindingType.Property:
if (view.genConfig.logBindingUpdate) {
@ -150,6 +151,8 @@ function bindAndWriteToRenderer(
targetViewExpr = compileElement.appElement.prop('componentView');
}
compileMethod = view.animationBindingsMethod;
var animationFnExpr =
targetViewExpr.prop('componentType').prop('animations').key(o.literal(animationName));
@ -178,19 +181,12 @@ function bindAndWriteToRenderer(
animationFnExpr.callFn([o.THIS_EXPR, renderNode, oldRenderValue, emptyStateValue])
.toStmt());
if (!_animationViewCheckedFlagMap.get(view)) {
_animationViewCheckedFlagMap.set(view, true);
var triggerStmt = o.THIS_EXPR.callMethod('triggerQueuedAnimations', []).toStmt();
view.afterViewLifecycleCallbacksMethod.addStmt(triggerStmt);
view.detachMethod.addStmt(triggerStmt);
}
break;
}
bind(
view, currValExpr, fieldExpr, boundProp.value, context, updateStmts,
view.detectChangesRenderPropertiesMethod, view.bindings.length);
view, currValExpr, fieldExpr, boundProp.value, context, updateStmts, compileMethod,
view.bindings.length);
});
}

View File

@ -574,12 +574,14 @@ function generateCreateMethod(view: CompileView): o.Statement[] {
function generateDetectChangesMethod(view: CompileView): o.Statement[] {
var stmts: any[] = [];
if (view.detectChangesInInputsMethod.isEmpty() && view.updateContentQueriesMethod.isEmpty() &&
if (view.animationBindingsMethod.isEmpty() && view.detectChangesInInputsMethod.isEmpty() &&
view.updateContentQueriesMethod.isEmpty() &&
view.afterContentLifecycleCallbacksMethod.isEmpty() &&
view.detectChangesRenderPropertiesMethod.isEmpty() &&
view.updateViewQueriesMethod.isEmpty() && view.afterViewLifecycleCallbacksMethod.isEmpty()) {
return stmts;
}
ListWrapper.addAll(stmts, view.animationBindingsMethod.finish());
ListWrapper.addAll(stmts, view.detectChangesInInputsMethod.finish());
stmts.push(
o.THIS_EXPR.callMethod('detectContentChildrenChanges', [DetectChangesVars.throwOnChange])