Skip to content

Commit

Permalink
fix(animations): support multiple state names per state() call (angul…
Browse files Browse the repository at this point in the history
  • Loading branch information
matsko authored and SamVerschueren committed Mar 18, 2017
1 parent 7788af0 commit 01fa17a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/animations/browser/src/dsl/animation_trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class AnimationTriggerVisitor implements AnimationDslVisitor {
}

visitState(ast: AnimationStateMetadata, context: any): any {
context.states[ast.name] = normalizeStyles(ast.styles.styles);
const styles = normalizeStyles(ast.styles.styles);
ast.name.split(/\s*,\s*/).forEach(name => { context.states[name] = styles; });
}

visitTransition(ast: AnimationTransitionMetadata, context: any): any {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ export function main() {
expect(result.transitionFactories.length).toEqual(2);
});

it('should allow multiple state values to use the same styles', () => {
const result = makeTrigger('name', [
state('on, off', style({width: 50})), transition('on => off', animate(1000)),
transition('off => on', animate(1000))
]);

expect(result.states).toEqual({'on': {width: 50}, 'off': {width: 50}});
});

it('should find the first transition that matches', () => {
const result = makeTrigger(
'name', [transition('a => b', animate(1234)), transition('b => c', animate(5678))]);
Expand Down

0 comments on commit 01fa17a

Please sign in to comment.