fix(animations): support multiple state names per state() call (#15147)
Closes #14732 Closes #15147
This commit is contained in:
		
							parent
							
								
									5c0ea20bd0
								
							
						
					
					
						commit
						36ce0afff6
					
				| @ -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 { | ||||
|  | ||||
| @ -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))]); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user