@@ -10,6 +10,7 @@ interface IndicatorProps extends ViewProps {
1010 stroke : number ;
1111 opacity : number ;
1212 vertical : boolean ;
13+ activeColor : string ;
1314 borderRadius : number ;
1415 animatedValue : Animated . Value | Animated . AnimatedInterpolation ;
1516}
@@ -23,10 +24,12 @@ const Indicator = ({
2324 stroke,
2425 opacity,
2526 vertical,
27+ activeColor,
2628 borderRadius,
2729 animatedValue,
2830} : IndicatorProps ) => {
2931 const offset = ( stroke - size ) / 2 ;
32+ const overlay = activeColor !== color ;
3033
3134 const wrapperTranslate = animatedValue . interpolate ( {
3235 inputRange : [ index - 1 , index , index + 1 ] ,
@@ -43,12 +46,22 @@ const Indicator = ({
4346 [ vertical ? 'marginVertical' : 'marginHorizontal' ] : gap / 2 ,
4447 opacity : animatedValue . interpolate ( {
4548 inputRange : [ index - 1 , index , index + 1 ] ,
46- outputRange : [ opacity , 1 , opacity ] ,
49+ outputRange : [ opacity , overlay ? 0 : 1 , opacity ] ,
4750 extrapolate : 'clamp' ,
4851 } ) ,
4952 transform : [ vertical ? { translateY : wrapperTranslate } : { translateX : wrapperTranslate } ] ,
5053 } ;
5154
55+ const overlayStyles : Animated . AnimatedProps < ViewStyle > = {
56+ ...wrapperStyles ,
57+ ...StyleSheet . absoluteFillObject ,
58+ opacity : animatedValue . interpolate ( {
59+ inputRange : [ index - 1 , index , index + 1 ] ,
60+ outputRange : [ 0 , 1 , 0 ] ,
61+ extrapolate : 'clamp' ,
62+ } ) ,
63+ } ;
64+
5265 const commonStyle : Animated . AnimatedProps < ViewStyle > = {
5366 width : vertical ? size : stroke / 2 ,
5467 height : vertical ? stroke / 2 : size ,
@@ -82,14 +95,26 @@ const Indicator = ({
8295 } ;
8396
8497 return (
85- < Animated . View style = { wrapperStyles } >
86- < View style = { styles . mask } >
87- < Animated . View style = { leftStyles } />
88- </ View >
89- < View style = { styles . mask } >
90- < Animated . View style = { rightStyles } />
91- </ View >
92- </ Animated . View >
98+ < View >
99+ < Animated . View style = { wrapperStyles } >
100+ < View style = { styles . mask } >
101+ < Animated . View style = { leftStyles } />
102+ </ View >
103+ < View style = { styles . mask } >
104+ < Animated . View style = { rightStyles } />
105+ </ View >
106+ </ Animated . View >
107+ { overlay && (
108+ < Animated . View style = { overlayStyles } >
109+ < View style = { styles . mask } >
110+ < Animated . View style = { [ leftStyles , { backgroundColor : activeColor } ] } />
111+ </ View >
112+ < View style = { styles . mask } >
113+ < Animated . View style = { [ rightStyles , { backgroundColor : activeColor } ] } />
114+ </ View >
115+ </ Animated . View >
116+ ) }
117+ </ View >
93118 ) ;
94119} ;
95120
0 commit comments