@@ -65,15 +65,15 @@ class SpringAnimation extends Animation {
65
65
_overshootClamping : boolean ;
66
66
_restDisplacementThreshold : number ;
67
67
_restSpeedThreshold : number ;
68
- _initialVelocity : ?number ;
69
68
_lastVelocity : number ;
70
69
_startPosition : number ;
71
70
_lastPosition : number ;
72
71
_fromValue : number ;
73
72
_toValue : any ;
74
- _stiffness : ?number ;
75
- _damping : ?number ;
76
- _mass : ?number ;
73
+ _stiffness : number ;
74
+ _damping : number ;
75
+ _mass : number ;
76
+ _initialVelocity : number ;
77
77
_delay : number ;
78
78
_timeout : any ;
79
79
_startTime : number ;
@@ -145,6 +145,10 @@ class SpringAnimation extends Animation {
145
145
this . _damping = springConfig . damping ;
146
146
this . _mass = 1 ;
147
147
}
148
+
149
+ invariant ( this . _stiffness > 0 , 'Stiffness value must be greater than 0' ) ;
150
+ invariant ( this . _damping > 0 , 'Damping value must be greater than 0' ) ;
151
+ invariant ( this . _mass > 0 , 'Mass value must be greater than 0' ) ;
148
152
}
149
153
150
154
__getNativeAnimationConfig ( ) {
@@ -243,20 +247,13 @@ class SpringAnimation extends Animation {
243
247
now = this . _lastTime + MAX_STEPS ;
244
248
}
245
249
246
- let deltaTime = 0.0 ;
247
- if ( now > this . _lastTime ) {
248
- deltaTime = ( now - this . _lastTime ) / 1000 ;
249
- }
250
+ const deltaTime = ( now - this . _lastTime ) / 1000 ;
250
251
this . _frameTime += deltaTime ;
251
252
252
- const c : number = this . _damping || 0 ;
253
- const m : number = this . _mass || 0 ;
254
- const k : number = this . _stiffness || 0 ;
255
- const v0 : number = - ( this . _initialVelocity || 0 ) ;
256
-
257
- invariant ( m > 0 , 'Mass value must be greater than 0' ) ;
258
- invariant ( k > 0 , 'Stiffness value must be greater than 0' ) ;
259
- invariant ( c > 0 , 'Damping value must be greater than 0' ) ;
253
+ const c : number = this . _damping ;
254
+ const m : number = this . _mass ;
255
+ const k : number = this . _stiffness ;
256
+ const v0 : number = - this . _initialVelocity ;
260
257
261
258
const zeta = c / ( 2 * Math . sqrt ( k * m ) ) ; // damping ratio
262
259
const omega0 = Math . sqrt ( k / m ) ; // undamped angular frequency of the oscillator (rad/ms)
0 commit comments