Skip to content

Commit

Permalink
v1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
kusalshrestha committed Jul 16, 2019
1 parent b73cfdd commit f317cf4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Example/AnimatedSegmentControl/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class App extends Component {
return (
<View style={styles.container}>
<SegmentControl
values={['Segment1', 'Segment2', 'Segment3']}
selectedIndex={0}
values={['Segment1', 'Segment2', 'Segment3', 'Segment4',]}
selectedIndex={1}
onChange={this.onSegmentValueChange}
/>
</View>
Expand Down
2 changes: 1 addition & 1 deletion Example/AnimatedSegmentControl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"react": "16.8.3",
"react-native": "0.59.10",
"react-native-animated-segment-control": "^1.0.7"
"react-native-animated-segment-control": "^1.0.8"
},
"devDependencies": {
"@babel/core": "^7.5.4",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-animated-segment-control",
"version": "1.0.7",
"version": "1.0.8",
"description": "A custom `SegmentControl` component, pretty much similar to native's SegmentControl but with animation",
"main": "index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/SegmentControl/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SegmentControl extends React.Component {
this.setState(
prevState => ({
selectedIndex: index,
activeSegmentPosition: { x: prevState.segmentDimension.width * (index - 1), y: 0 }
activeSegmentPosition: { x: -(this.state.segmentDimension.width * (this.props.values.length / 2 - 0.5)) + this.state.segmentDimension.width * index, y: prevState.activeSegmentPosition.y }
}),
animate
)
Expand All @@ -56,7 +56,7 @@ class SegmentControl extends React.Component {

const animate = () => {
Animated.timing(this.state.positionAnimationValue, {
toValue: segmentWidth * (this.state.selectedIndex - 1),
toValue: -(segmentWidth * (this.props.values.length / 2 - 0.5)) + segmentWidth * this.state.selectedIndex,
duration: 100
}).start()
}
Expand Down

0 comments on commit f317cf4

Please sign in to comment.