Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/MaterialTabBar/Indicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const Indicator: React.FC<IndicatorProps> = ({
}) => {
const opacity = useSharedValue(fadeIn ? 0 : 1)

const layoutForDirection = isRTL ? itemsLayout.slice().reverse() : itemsLayout

const stylez = useAnimatedStyle(() => {
const firstItemX = itemsLayout[0]?.x ?? 0

Expand All @@ -28,21 +30,18 @@ const Indicator: React.FC<IndicatorProps> = ({
? interpolate(
indexDecimal.value,
itemsLayout.map((_, i) => i),
// when in RTL mode, the X value should be inverted
itemsLayout.map((v) => (isRTL ? -1 * v.x : v.x))
layoutForDirection.map((v) => v.x)
)
: isRTL
? -1 * firstItemX
: firstItemX,
: firstItemX,
},
]

const width =
itemsLayout.length > 1
? interpolate(
indexDecimal.value,
itemsLayout.map((_, i) => i),
itemsLayout.map((v) => v.width)
layoutForDirection.map((_, i) => i),
layoutForDirection.map((v) => v.width)
)
: itemsLayout[0]?.width

Expand All @@ -69,6 +68,8 @@ const styles = StyleSheet.create({
backgroundColor: '#2196f3',
position: 'absolute',
bottom: 0,
left: isRTL ? undefined : 0,
right: isRTL ? 0 : undefined,
},
})

Expand Down