@@ -13,6 +13,7 @@ export interface ExpandingDotProps {
13
13
containerStyle : ViewStyle ;
14
14
dotStyle : ViewStyle ;
15
15
inActiveDotOpacity ?: number ;
16
+ inActiveDotColor ?: string ;
16
17
expandingDotWidth ?: number ;
17
18
}
18
19
@@ -24,9 +25,11 @@ const ExpandingDot = ({
24
25
dotStyle,
25
26
containerStyle,
26
27
inActiveDotOpacity,
28
+ inActiveDotColor,
27
29
expandingDotWidth,
28
30
} : ExpandingDotProps ) => {
29
31
const defaultProps = {
32
+ inActiveDotColor : inActiveDotColor || dotStyle . backgroundColor . toString ( ) ,
30
33
inActiveDotOpacity : inActiveDotOpacity || 0.5 ,
31
34
expandingDotWidth : expandingDotWidth || 20 ,
32
35
dotWidth : ( dotStyle . width as number ) || 10 ,
@@ -41,6 +44,15 @@ const ExpandingDot = ({
41
44
( index + 1 ) * width ,
42
45
] ;
43
46
47
+ const colour = scrollX . interpolate ( {
48
+ inputRange,
49
+ outputRange : [
50
+ defaultProps . inActiveDotColor ,
51
+ dotStyle . backgroundColor . toString ( ) ,
52
+ defaultProps . inActiveDotColor ,
53
+ ] ,
54
+ extrapolate : 'clamp' ,
55
+ } ) ;
44
56
const opacity = scrollX . interpolate ( {
45
57
inputRange,
46
58
outputRange : [
@@ -63,7 +75,7 @@ const ExpandingDot = ({
63
75
return (
64
76
< Animated . View
65
77
key = { `dot-${ index } ` }
66
- style = { [ styles . dotStyle , dotStyle , { width : expand } , { opacity } ] }
78
+ style = { [ styles . dotStyle , dotStyle , { width : expand } , { opacity } , { backgroundColor : colour } ] }
67
79
/>
68
80
) ;
69
81
} ) }
0 commit comments