Skip to content

Commit 68652d8

Browse files
authored
Fix Animation Active segmant width in RTL (#121)
1 parent 298b878 commit 68652d8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

js/SegmentedControl.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
'use strict';
66

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

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

4444
React.useEffect(() => {
4545
if (animation && segmentWidth) {
46+
let isRTL = I18nManager.isRTL ? -segmentWidth : segmentWidth;
4647
Animated.timing(animation, {
47-
toValue: segmentWidth * (selectedIndex || 0),
48+
toValue: isRTL * (selectedIndex || 0),
4849
duration: 300,
4950
easing: Easing.out(Easing.quad),
5051
useNativeDriver: true,

0 commit comments

Comments
 (0)