Skip to content

Commit

Permalink
Fix Animation Active segmant width in RTL (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
anastely committed Sep 16, 2020
1 parent 298b878 commit 68652d8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions js/SegmentedControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'use strict';

import * as React from 'react';
import {Animated, Easing, StyleSheet, View} from 'react-native';
import {Animated, I18nManager, Easing, StyleSheet, View} from 'react-native';
import {SegmentedControlTab} from './SegmentedControlTab';

import type {SegmentedControlProps} from './types';
Expand Down Expand Up @@ -43,8 +43,9 @@ const SegmentedControl = ({

React.useEffect(() => {
if (animation && segmentWidth) {
let isRTL = I18nManager.isRTL ? -segmentWidth : segmentWidth;
Animated.timing(animation, {
toValue: segmentWidth * (selectedIndex || 0),
toValue: isRTL * (selectedIndex || 0),
duration: 300,
easing: Easing.out(Easing.quad),
useNativeDriver: true,
Expand Down

0 comments on commit 68652d8

Please sign in to comment.