@@ -20,6 +20,10 @@ const _INITIAL_KEYFRAME = 0;
20
20
const _TERMINAL_KEYFRAME = 1 ;
21
21
const _ONE_SECOND = 1000 ;
22
22
23
+ declare type Styles = {
24
+ [ key : string ] : string | number
25
+ } ;
26
+
23
27
export class AnimationParseError extends ParseError {
24
28
constructor ( message : string ) { super ( null , message ) ; }
25
29
toString ( ) : string { return `${ this . msg } ` ; }
@@ -90,11 +94,11 @@ export class AnimationParser {
90
94
function _parseAnimationDeclarationStates (
91
95
stateMetadata : CompileAnimationStateDeclarationMetadata ,
92
96
errors : AnimationParseError [ ] ) : AnimationStateDeclarationAst [ ] {
93
- var styleValues : { [ key : string ] : string | number } [ ] = [ ] ;
97
+ var styleValues : Styles [ ] = [ ] ;
94
98
stateMetadata . styles . styles . forEach ( stylesEntry => {
95
99
// TODO (matsko): change this when we get CSS class integration support
96
100
if ( isStringMap ( stylesEntry ) ) {
97
- styleValues . push ( < { [ key : string ] : string | number } > stylesEntry ) ;
101
+ styleValues . push ( stylesEntry as Styles ) ;
98
102
} else {
99
103
errors . push ( new AnimationParseError (
100
104
`State based animations cannot contain references to other states` ) ) ;
@@ -169,16 +173,6 @@ function _parseAnimationTransitionExpr(
169
173
return expressions ;
170
174
}
171
175
172
- function _fetchSylesFromState ( stateName : string , stateStyles : { [ key : string ] : AnimationStylesAst } ) :
173
- CompileAnimationStyleMetadata {
174
- var entry = stateStyles [ stateName ] ;
175
- if ( isPresent ( entry ) ) {
176
- var styles = < { [ key : string ] : string | number } [ ] > entry . styles ;
177
- return new CompileAnimationStyleMetadata ( 0 , styles ) ;
178
- }
179
- return null ;
180
- }
181
-
182
176
function _normalizeAnimationEntry ( entry : CompileAnimationMetadata | CompileAnimationMetadata [ ] ) :
183
177
CompileAnimationMetadata {
184
178
return isArray ( entry ) ? new CompileAnimationSequenceMetadata ( < CompileAnimationMetadata [ ] > entry ) :
@@ -234,7 +228,7 @@ function _normalizeStyleStepEntry(
234
228
}
235
229
236
230
var newSteps : CompileAnimationMetadata [ ] = [ ] ;
237
- var combinedStyles : { [ key : string ] : string | number } [ ] ;
231
+ var combinedStyles : Styles [ ] ;
238
232
steps . forEach ( step => {
239
233
if ( step instanceof CompileAnimationStyleMetadata ) {
240
234
// this occurs when a style step is followed by a previous style step
@@ -290,7 +284,7 @@ function _normalizeStyleStepEntry(
290
284
function _resolveStylesFromState (
291
285
stateName : string , stateStyles : { [ key : string ] : AnimationStylesAst } ,
292
286
errors : AnimationParseError [ ] ) {
293
- var styles : { [ key : string ] : string | number } [ ] = [ ] ;
287
+ var styles : Styles [ ] = [ ] ;
294
288
if ( stateName [ 0 ] != ':' ) {
295
289
errors . push ( new AnimationParseError ( `Animation states via styles must be prefixed with a ":"` ) ) ;
296
290
} else {
@@ -302,7 +296,7 @@ function _resolveStylesFromState(
302
296
} else {
303
297
value . styles . forEach ( stylesEntry => {
304
298
if ( isStringMap ( stylesEntry ) ) {
305
- styles . push ( < { [ key : string ] : string | number } > stylesEntry ) ;
299
+ styles . push ( stylesEntry as Styles ) ;
306
300
}
307
301
} ) ;
308
302
}
@@ -336,15 +330,13 @@ function _parseAnimationKeyframes(
336
330
var lastOffset = 0 ;
337
331
keyframeSequence . steps . forEach ( styleMetadata => {
338
332
var offset = styleMetadata . offset ;
339
- var keyframeStyles : { [ key : string ] : string | number } = { } ;
333
+ var keyframeStyles : Styles = { } ;
340
334
styleMetadata . styles . forEach ( entry => {
341
- StringMapWrapper . forEach (
342
- < { [ key : string ] : string | number } > entry ,
343
- ( value : any /** TODO #9100 */ , prop : any /** TODO #9100 */ ) => {
344
- if ( prop != 'offset' ) {
345
- keyframeStyles [ prop ] = value ;
346
- }
347
- } ) ;
335
+ Object . keys ( entry ) . forEach ( prop => {
336
+ if ( prop != 'offset' ) {
337
+ keyframeStyles [ prop ] = ( entry as Styles ) [ prop ] ;
338
+ }
339
+ } ) ;
348
340
} ) ;
349
341
350
342
if ( isPresent ( offset ) ) {
@@ -381,24 +373,22 @@ function _parseAnimationKeyframes(
381
373
let entry = rawKeyframes [ i ] ;
382
374
let styles = entry [ 1 ] ;
383
375
384
- StringMapWrapper . forEach (
385
- styles , ( value : any /** TODO #9100 */ , prop : any /** TODO #9100 */ ) => {
386
- if ( ! isPresent ( firstKeyframeStyles [ prop ] ) ) {
387
- firstKeyframeStyles [ prop ] = FILL_STYLE_FLAG ;
388
- }
389
- } ) ;
376
+ Object . keys ( styles ) . forEach ( prop => {
377
+ if ( ! isPresent ( firstKeyframeStyles [ prop ] ) ) {
378
+ firstKeyframeStyles [ prop ] = FILL_STYLE_FLAG ;
379
+ }
380
+ } ) ;
390
381
}
391
382
392
383
for ( i = limit - 1 ; i >= 0 ; i -- ) {
393
384
let entry = rawKeyframes [ i ] ;
394
385
let styles = entry [ 1 ] ;
395
386
396
- StringMapWrapper . forEach (
397
- styles , ( value : any /** TODO #9100 */ , prop : any /** TODO #9100 */ ) => {
398
- if ( ! isPresent ( lastKeyframeStyles [ prop ] ) ) {
399
- lastKeyframeStyles [ prop ] = value ;
400
- }
401
- } ) ;
387
+ Object . keys ( styles ) . forEach ( prop => {
388
+ if ( ! isPresent ( lastKeyframeStyles [ prop ] ) ) {
389
+ lastKeyframeStyles [ prop ] = styles [ prop ] ;
390
+ }
391
+ } ) ;
402
392
}
403
393
404
394
return rawKeyframes . map (
@@ -422,11 +412,9 @@ function _parseTransitionAnimation(
422
412
if ( entry instanceof CompileAnimationStyleMetadata ) {
423
413
entry . styles . forEach ( stylesEntry => {
424
414
// by this point we know that we only have stringmap values
425
- var map = < { [ key : string ] : string | number } > stylesEntry ;
426
- StringMapWrapper . forEach (
427
- map , ( value : any /** TODO #9100 */ , prop : any /** TODO #9100 */ ) => {
428
- collectedStyles . insertAtTime ( prop , time , value ) ;
429
- } ) ;
415
+ var map = stylesEntry as Styles ;
416
+ Object . keys ( map ) . forEach (
417
+ prop => { collectedStyles . insertAtTime ( prop , time , map [ prop ] ) ; } ) ;
430
418
} ) ;
431
419
previousStyles = entry . styles ;
432
420
return ;
@@ -472,7 +460,7 @@ function _parseTransitionAnimation(
472
460
} else {
473
461
let styleData = < CompileAnimationStyleMetadata > styles ;
474
462
let offset = _TERMINAL_KEYFRAME ;
475
- let styleAst = new AnimationStylesAst ( < { [ key : string ] : string | number } [ ] > styleData . styles ) ;
463
+ let styleAst = new AnimationStylesAst ( styleData . styles as Styles [ ] ) ;
476
464
var keyframe = new AnimationKeyframeAst ( offset , styleAst ) ;
477
465
keyframes = [ keyframe ] ;
478
466
}
@@ -484,9 +472,8 @@ function _parseTransitionAnimation(
484
472
485
473
keyframes . forEach (
486
474
( keyframe : any /** TODO #9100 */ ) => keyframe . styles . styles . forEach (
487
- ( entry : any /** TODO #9100 */ ) => StringMapWrapper . forEach (
488
- entry , ( value : any /** TODO #9100 */ , prop : any /** TODO #9100 */ ) =>
489
- collectedStyles . insertAtTime ( prop , currentTime , value ) ) ) ) ;
475
+ ( entry : any /** TODO #9100 */ ) => Object . keys ( entry ) . forEach (
476
+ prop => { collectedStyles . insertAtTime ( prop , currentTime , entry [ prop ] ) ; } ) ) ) ;
490
477
} else {
491
478
// if the code reaches this stage then an error
492
479
// has already been populated within the _normalizeStyleSteps()
@@ -559,10 +546,11 @@ function _parseTimeExpression(
559
546
function _createStartKeyframeFromEndKeyframe (
560
547
endKeyframe : AnimationKeyframeAst , startTime : number , duration : number ,
561
548
collectedStyles : StylesCollection , errors : AnimationParseError [ ] ) : AnimationKeyframeAst {
562
- var values : { [ key : string ] : string | number } = { } ;
549
+ var values : Styles = { } ;
563
550
var endTime = startTime + duration ;
564
- endKeyframe . styles . styles . forEach ( ( styleData : { [ key : string ] : string | number } ) => {
565
- StringMapWrapper . forEach ( styleData , ( val : any /** TODO #9100 */ , prop : any /** TODO #9100 */ ) => {
551
+ endKeyframe . styles . styles . forEach ( ( styleData : Styles ) => {
552
+ Object . keys ( styleData ) . forEach ( prop => {
553
+ const val = styleData [ prop ] ;
566
554
if ( prop == 'offset' ) return ;
567
555
568
556
var resultIndex = collectedStyles . indexOfAtOrBeforeTime ( prop , startTime ) ;
0 commit comments