Skip to content

Commit

Permalink
fix: indicator display for single tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerumen committed Apr 12, 2024
1 parent e5d3455 commit ed67c03
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/MaterialTabBar/Indicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,21 @@ const Indicator: React.FC<IndicatorProps> = ({
const opacity = useSharedValue(fadeIn ? 0 : 1)

const stylez = useAnimatedStyle(() => {
const transform =
itemsLayout.length > 1
? [
{
translateX: interpolate(
const transform = [
{
translateX:
itemsLayout.length > 1
? 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))
),
},
]
: undefined
)
: isRTL
? -1 * itemsLayout[0]?.x
: itemsLayout[0]?.x,
},
]

const width =
itemsLayout.length > 1
Expand Down

0 comments on commit ed67c03

Please sign in to comment.