@@ -26,6 +26,7 @@ export class Animation {
26
26
private _rv : boolean ;
27
27
private _unregTrans : Function ;
28
28
private _tmr : any ;
29
+ private _lastUpd : number = 0 ;
29
30
30
31
public isPlaying : boolean ;
31
32
public hasTween : boolean ;
@@ -174,7 +175,7 @@ export class Animation {
174
175
} ;
175
176
176
177
if ( typeof val === 'string' && val . indexOf ( ' ' ) < 0 ) {
177
- let r = val . match ( / ( ^ - ? \d * \. ? \d * ) ( . * ) / ) ;
178
+ let r = val . match ( cssValueRegex ) ;
178
179
let num = parseFloat ( r [ 1 ] ) ;
179
180
180
181
if ( ! isNaN ( num ) ) {
@@ -600,17 +601,26 @@ export class Animation {
600
601
}
601
602
602
603
progressStep ( stepValue : number ) {
603
- stepValue = Math . min ( 1 , Math . max ( 0 , stepValue ) ) ;
604
+ let now = Date . now ( ) ;
604
605
605
- for ( var i = 0 ; i < this . _c . length ; i ++ ) {
606
- this . _c [ i ] . progressStep ( stepValue ) ;
607
- }
606
+ // only update if the last update was more than 16ms ago
607
+ if ( now - 16 > this . _lastUpd ) {
608
+ this . _lastUpd = now ;
608
609
609
- if ( this . _rv ) {
610
- stepValue = ( ( stepValue * - 1 ) + 1 ) ;
611
- }
610
+ stepValue = Math . min ( 1 , Math . max ( 0 , stepValue ) ) ;
612
611
613
- this . _progress ( stepValue ) ;
612
+ for ( var i = 0 ; i < this . _c . length ; i ++ ) {
613
+ this . _c [ i ] . progressStep ( stepValue ) ;
614
+ }
615
+
616
+ if ( this . _rv ) {
617
+ // if the animation is going in reverse then
618
+ // flip the step value: 0 becomes 1, 1 becomes 0
619
+ stepValue = ( ( stepValue * - 1 ) + 1 ) ;
620
+ }
621
+
622
+ this . _progress ( stepValue ) ;
623
+ }
614
624
}
615
625
616
626
progressEnd ( shouldComplete : boolean , currentStepValue : number ) {
@@ -765,4 +775,6 @@ const TRANSFORMS = {
765
775
'skewX' :1 , 'skewY' :1 , 'perspective' :1
766
776
} ;
767
777
778
+ const cssValueRegex = / ( ^ - ? \d * \. ? \d * ) ( .* ) / ;
779
+
768
780
let AnimationRegistry = { } ;
0 commit comments