import * as React from 'react' ; import { Animated , View } from 'react-native' ; import { SpinnerProps , defaultProps } from './SpinnerProps' ; import AnimationContainer from './AnimationContainer' ; import { stagger } from './utils' ; export default class CircleFade extends React . Component < SpinnerProps > { static defaultProps = defaultProps ; render ( ) { const { size , color , style , animating , hidesWhenStopped , ... rest } = this . props ; const circleStyle = { position : 'absolute' , width : size * 0.15 , height : size * 0.15 , backgroundColor : color , borderRadius : ( size * 0.15 ) / 2 } ; return ( < AnimationContainer initAnimation = { ( ) => ( { circleFade : ( value ) => stagger ( 100 , 12 , { duration : 1200 , value : value , keyframes : [ 0 , 39 , 40 , 100 ] } ) } ) } animating = { animating } > { ( values ) => ( < View style = { [ { width : size , height : size , alignItems : 'center' , justifyContent : 'center' , opacity : ! animating && hidesWhenStopped ? 0 : 1 } , style , ] } { ... rest } > { values . circleFade . map ( ( value , index ) => ( < Animated . View key = { index } style = { [ circleStyle , { opacity : value . interpolate ( { inputRange : [ 0 , 39 , 40 , 100 ] , outputRange : [ 0 , 0 , 1 , 0 ] } ) , transform : [ { rotate : `${ index * 30 }deg` } , { translateY : - size / 2 + ( size * 0.15 ) / 2 } , { scale : value . interpolate ( { inputRange : [ 0 , 39 , 40 , 100 ] , outputRange : [ 0.6 , 0.6 , 1 , 0.6 ] } ) } , ] } , ] } / > ) ) } < /View>)} < /AnimationContainer>); } }