@@ -2,13 +2,54 @@ import * as React from 'react'
22import { Animated , Easing } from 'react-native'
33import { SpinnerProps , defaultProps } from './SpinnerProps'
44import AnimationContainer from './AnimationContainer'
5- import { anim , createAnimatedValues } from './utils'
5+ import { anim , stagger } from './utils'
66
77export default class Chase extends React . Component < SpinnerProps > {
88 static defaultProps = defaultProps
9- chaseDotValues = createAnimatedValues ( 6 )
10- chaseDotBeforeValues = createAnimatedValues ( 6 )
9+
1110 chase = new Animated . Value ( 0 )
11+ chaseDot = new Animated . Value ( 0 )
12+ chaseDotValues : Animated . AnimatedInterpolation [ ]
13+ chaseDotBefore = new Animated . Value ( 0 )
14+ chaseDotBeforeValues : Animated . AnimatedInterpolation [ ]
15+ animation : Animated . CompositeAnimation
16+
17+ constructor ( props : SpinnerProps ) {
18+ super ( props )
19+
20+ const { animation : chaseDotAnimation , values : chaseDotValues } = stagger (
21+ 100 ,
22+ 6 ,
23+ {
24+ duration : 2000 ,
25+ value : this . chaseDot ,
26+ keyframes : [ 0 , 80 , 100 ] ,
27+ }
28+ )
29+ this . chaseDotValues = chaseDotValues
30+
31+ const {
32+ animation : chaseDotBeforeAnimation ,
33+ values : chaseDotBeforeValues ,
34+ } = stagger ( 100 , 6 , {
35+ duration : 2000 ,
36+ value : this . chaseDot ,
37+ keyframes : [ 0 , 80 , 100 ] ,
38+ } )
39+ this . chaseDotBeforeValues = chaseDotBeforeValues
40+
41+ const chaseAnimation = anim ( {
42+ duration : 2500 ,
43+ easing : Easing . linear ,
44+ value : this . chase ,
45+ } )
46+
47+ this . animation = Animated . parallel ( [
48+ chaseAnimation ,
49+ chaseDotAnimation ,
50+ chaseDotBeforeAnimation ,
51+ ] )
52+ }
1253
1354 render ( ) {
1455 const { size, color, style, ...rest } = this . props
@@ -20,35 +61,7 @@ export default class Chase extends React.Component<SpinnerProps> {
2061 borderRadius : size / 8 ,
2162 }
2263 return (
23- < AnimationContainer
24- animation = { Animated . parallel ( [
25- Animated . parallel (
26- this . chaseDotValues . map ( ( value , index ) =>
27- anim ( {
28- duration : 2000 ,
29- value : value ,
30- keyframes : [ 0 , 80 , 100 ] ,
31- delay : index * 100 ,
32- } )
33- )
34- ) ,
35- Animated . parallel (
36- this . chaseDotBeforeValues . map ( ( value , index ) =>
37- anim ( {
38- duration : 2000 ,
39- value : value ,
40- keyframes : [ 0 , 50 , 100 ] ,
41- delay : index * 100 ,
42- } )
43- )
44- ) ,
45- anim ( {
46- duration : 2500 ,
47- easing : Easing . linear ,
48- value : this . chase ,
49- } ) ,
50- ] ) }
51- >
64+ < AnimationContainer animation = { this . animation } >
5265 < Animated . View
5366 style = { [
5467 {
0 commit comments