@@ -65,15 +65,15 @@ class SpringAnimation extends Animation {
6565 _overshootClamping : boolean ;
6666 _restDisplacementThreshold : number ;
6767 _restSpeedThreshold : number ;
68- _initialVelocity : ?number ;
6968 _lastVelocity : number ;
7069 _startPosition : number ;
7170 _lastPosition : number ;
7271 _fromValue : number ;
7372 _toValue : any ;
74- _stiffness : ?number ;
75- _damping : ?number ;
76- _mass : ?number ;
73+ _stiffness : number ;
74+ _damping : number ;
75+ _mass : number ;
76+ _initialVelocity : number ;
7777 _delay : number ;
7878 _timeout : any ;
7979 _startTime : number ;
@@ -145,6 +145,10 @@ class SpringAnimation extends Animation {
145145 this . _damping = springConfig . damping ;
146146 this . _mass = 1 ;
147147 }
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' ) ;
148152 }
149153
150154 __getNativeAnimationConfig ( ) {
@@ -243,20 +247,13 @@ class SpringAnimation extends Animation {
243247 now = this . _lastTime + MAX_STEPS ;
244248 }
245249
246- let deltaTime = 0.0 ;
247- if ( now > this . _lastTime ) {
248- deltaTime = ( now - this . _lastTime ) / 1000 ;
249- }
250+ const deltaTime = ( now - this . _lastTime ) / 1000 ;
250251 this . _frameTime += deltaTime ;
251252
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 ;
260257
261258 const zeta = c / ( 2 * Math . sqrt ( k * m ) ) ; // damping ratio
262259 const omega0 = Math . sqrt ( k / m ) ; // undamped angular frequency of the oscillator (rad/ms)
0 commit comments