Skip to content

Commit

Permalink
fix: nan value issue
Browse files Browse the repository at this point in the history
  • Loading branch information
24ark committed Jun 16, 2020
1 parent c45e39b commit cf35b97
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ const StepIndicator = ({
const sizeAnim = React.useRef(
new Animated.Value(customStyles.stepIndicatorSize)
).current;
const staleSizeAnim = React.useRef(
new Animated.Value(customStyles.stepIndicatorSize)
).current;
const borderRadiusAnim = React.useRef(
new Animated.Value(customStyles.stepIndicatorSize / 2)
).current;
Expand Down Expand Up @@ -243,6 +246,9 @@ const StepIndicator = ({
};

const renderStepLabels = () => {
if (!labels || labels.length === 0) {
return;
}
var labelViews = labels.map((label, index) => {
const selectedStepLabelStyle =
index === currentPosition
Expand Down Expand Up @@ -308,8 +314,10 @@ const StepIndicator = ({
height: sizeAnim,
width: sizeAnim,
borderRadius: borderRadiusAnim,
overflow: 'hidden',
};
indicatorLabelStyle = {
overflow: 'hidden',
fontSize: customStyles.currentStepIndicatorLabelFontSize,
color: customStyles.stepIndicatorLabelCurrentColor,
};
Expand All @@ -321,11 +329,13 @@ const StepIndicator = ({
backgroundColor: customStyles.stepIndicatorFinishedColor,
borderWidth: customStyles.stepStrokeWidth,
borderColor: customStyles.stepStrokeFinishedColor,
height: customStyles.stepIndicatorSize,
width: customStyles.stepIndicatorSize,
height: staleSizeAnim,
width: staleSizeAnim,
borderRadius: customStyles.stepIndicatorSize / 2,
overflow: 'hidden',
};
indicatorLabelStyle = {
overflow: 'hidden',
fontSize: customStyles.stepIndicatorLabelFontSize,
color: customStyles.stepIndicatorLabelFinishedColor,
};
Expand All @@ -337,9 +347,10 @@ const StepIndicator = ({
backgroundColor: customStyles.stepIndicatorUnFinishedColor,
borderWidth: customStyles.stepStrokeWidth,
borderColor: customStyles.stepStrokeUnFinishedColor,
height: customStyles.stepIndicatorSize,
width: customStyles.stepIndicatorSize,
height: staleSizeAnim,
width: staleSizeAnim,
borderRadius: customStyles.stepIndicatorSize / 2,
overflow: 'hidden',
};
indicatorLabelStyle = {
overflow: 'hidden',
Expand Down Expand Up @@ -381,10 +392,11 @@ const StepIndicator = ({
}
const animateToPosition = (progressBarSize / (stepCount - 1)) * position;
sizeAnim.setValue(customStyles.stepIndicatorSize);
staleSizeAnim.setValue(customStyles.stepIndicatorSize);
borderRadiusAnim.setValue(customStyles.stepIndicatorSize / 2);
Animated.sequence([
Animated.timing(progressAnim, {
toValue: animateToPosition,
toValue: isNaN(animateToPosition) ? 0 : animateToPosition,
duration: 200,
useNativeDriver: false,
}),
Expand Down Expand Up @@ -426,13 +438,13 @@ const StepIndicator = ({

const styles = StyleSheet.create({
container: {
backgroundColor: 'transparent',
backgroundColor: 'rgba(1,0,0,0)',
},
stepIndicatorContainer: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-around',
backgroundColor: 'transparent',
backgroundColor: 'rgba(1,0,0,0)',
},
stepLabelsContainer: {
justifyContent: 'space-around',
Expand Down

0 comments on commit cf35b97

Please sign in to comment.