Skip to content

Commit 68626d1

Browse files
committed
Inactive Colours Added
1 parent e55543a commit 68626d1

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/dots/ExpandingDot.tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface ExpandingDotProps {
1313
containerStyle: ViewStyle;
1414
dotStyle: ViewStyle;
1515
inActiveDotOpacity?: number;
16+
inActiveDotColor?: string;
1617
expandingDotWidth?: number;
1718
}
1819

@@ -24,9 +25,11 @@ const ExpandingDot = ({
2425
dotStyle,
2526
containerStyle,
2627
inActiveDotOpacity,
28+
inActiveDotColor,
2729
expandingDotWidth,
2830
}: ExpandingDotProps) => {
2931
const defaultProps = {
32+
inActiveDotColor: inActiveDotColor || dotStyle.backgroundColor.toString(),
3033
inActiveDotOpacity: inActiveDotOpacity || 0.5,
3134
expandingDotWidth: expandingDotWidth || 20,
3235
dotWidth: (dotStyle.width as number) || 10,
@@ -41,6 +44,15 @@ const ExpandingDot = ({
4144
(index + 1) * width,
4245
];
4346

47+
const colour = scrollX.interpolate({
48+
inputRange,
49+
outputRange: [
50+
defaultProps.inActiveDotColor,
51+
dotStyle.backgroundColor.toString(),
52+
defaultProps.inActiveDotColor,
53+
],
54+
extrapolate: 'clamp',
55+
});
4456
const opacity = scrollX.interpolate({
4557
inputRange,
4658
outputRange: [
@@ -63,7 +75,7 @@ const ExpandingDot = ({
6375
return (
6476
<Animated.View
6577
key={`dot-${index}`}
66-
style={[styles.dotStyle, dotStyle, { width: expand }, { opacity }]}
78+
style={[styles.dotStyle, dotStyle, { width: expand }, { opacity }, { backgroundColor: colour }]}
6779
/>
6880
);
6981
})}

src/dots/ScalingDot.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface ScalingDotProps {
1313
containerStyle?: ViewStyle;
1414
dotStyle?: ViewStyle;
1515
inActiveDotOpacity?: number;
16+
inActiveDotColor?: string;
1617
activeDotScale?: number;
1718
}
1819

@@ -24,9 +25,11 @@ const ScalingDot = ({
2425
dotStyle,
2526
containerStyle,
2627
inActiveDotOpacity,
28+
inActiveDotColor,
2729
activeDotScale,
2830
}: ScalingDotProps) => {
2931
const defaultProps = {
32+
inActiveDotColor: inActiveDotColor || dotStyle.backgroundColor.toString(),
3033
animationType: 'scale',
3134
inActiveDotOpacity: inActiveDotOpacity || 0.5,
3235
activeDotScale: activeDotScale || 1.4,
@@ -41,6 +44,15 @@ const ScalingDot = ({
4144
(index + 1) * width,
4245
];
4346

47+
const colour = scrollX.interpolate({
48+
inputRange,
49+
outputRange: [
50+
defaultProps.inActiveDotColor,
51+
dotStyle.backgroundColor.toString(),
52+
defaultProps.inActiveDotColor,
53+
],
54+
extrapolate: 'clamp',
55+
});
4456
const opacity = scrollX.interpolate({
4557
inputRange,
4658
outputRange: [
@@ -64,6 +76,7 @@ const ScalingDot = ({
6476
{ opacity },
6577
{ transform: [{ scale }] },
6678
dotStyle,
79+
{ backgroundColor: colour },
6780
]}
6881
/>
6982
);

0 commit comments

Comments
 (0)