@@ -85,6 +85,8 @@ const {
8585 onChange,
8686 set,
8787 spring,
88+ // @ts -ignore
89+ proc,
8890 sub,
8991 timing,
9092 startClock,
@@ -94,6 +96,79 @@ const {
9496 Value,
9597} = Animated ;
9698
99+ const springHelper = proc (
100+ (
101+ finished : Animated . Value < number > ,
102+ velocity : Animated . Value < number > ,
103+ position : Animated . Value < number > ,
104+ time : Animated . Value < number > ,
105+ prevPosition : Animated . Value < number > ,
106+ toValue : Animated . Adaptable < number > ,
107+ damping : Animated . Adaptable < number > ,
108+ mass : Animated . Adaptable < number > ,
109+ stiffness : Animated . Adaptable < number > ,
110+ overshootClamping : Animated . Adaptable < number > ,
111+ restSpeedThreshold : Animated . Adaptable < number > ,
112+ restDisplacementThreshold : Animated . Adaptable < number > ,
113+ clock : Animated . Clock
114+ ) =>
115+ spring (
116+ clock ,
117+ {
118+ finished,
119+ velocity,
120+ position,
121+ time,
122+ // @ts -ignore
123+ prevPosition,
124+ } ,
125+ {
126+ toValue,
127+ damping,
128+ mass,
129+ stiffness,
130+ overshootClamping,
131+ restDisplacementThreshold,
132+ restSpeedThreshold,
133+ }
134+ )
135+ ) ;
136+
137+ function memoizedSpring (
138+ clock : Animated . Clock ,
139+ state : {
140+ finished : Animated . Value < number > ;
141+ velocity : Animated . Value < number > ;
142+ position : Animated . Value < number > ;
143+ time : Animated . Value < number > ;
144+ } ,
145+ config : {
146+ toValue : Animated . Adaptable < number > ;
147+ damping : Animated . Adaptable < number > ;
148+ mass : Animated . Adaptable < number > ;
149+ stiffness : Animated . Adaptable < number > ;
150+ overshootClamping : Animated . Adaptable < boolean > ;
151+ restSpeedThreshold : Animated . Adaptable < number > ;
152+ restDisplacementThreshold : Animated . Adaptable < number > ;
153+ }
154+ ) {
155+ return springHelper (
156+ state . finished ,
157+ state . velocity ,
158+ state . position ,
159+ state . time ,
160+ new Value ( 0 ) ,
161+ config . toValue ,
162+ config . damping ,
163+ config . mass ,
164+ config . stiffness ,
165+ config . overshootClamping ,
166+ config . restSpeedThreshold ,
167+ config . restDisplacementThreshold ,
168+ clock
169+ ) ;
170+ }
171+
97172export default class Card extends React . Component < Props > {
98173 static defaultProps = {
99174 overlayEnabled : Platform . OS !== 'ios' ,
@@ -203,7 +278,7 @@ export default class Card extends React.Component<Props> {
203278 cond (
204279 eq ( isVisible , 1 ) ,
205280 openingSpec . timing === 'spring'
206- ? spring (
281+ ? memoizedSpring (
207282 this . clock ,
208283 { ...this . transitionState , velocity : this . transitionVelocity } ,
209284 { ...openingSpec . config , toValue : this . toValue }
@@ -214,7 +289,7 @@ export default class Card extends React.Component<Props> {
214289 { ...openingSpec . config , toValue : this . toValue }
215290 ) ,
216291 closingSpec . timing === 'spring'
217- ? spring (
292+ ? memoizedSpring (
218293 this . clock ,
219294 { ...this . transitionState , velocity : this . transitionVelocity } ,
220295 { ...closingSpec . config , toValue : this . toValue }
0 commit comments