Skip to content

Commit

Permalink
fix(rn-tabbar): calc tab bar indicator position
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Jan 12, 2025
1 parent 0a64473 commit e625ada
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/mobile/src/components/ui/tabview/TabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const TabBar = forwardRef<ScrollView, TabBarProps>(
}, [currentTab, indicatorPosition, sharedPagerOffsetX.value, tabPositions, tabWidths])

const indicatorStyle = useAnimatedStyle(() => {
const scrollProgress = sharedPagerOffsetX.value / tabBarWidth
const scrollProgress = Math.max(sharedPagerOffsetX.value / tabBarWidth, 0)

const currentIndex = Math.floor(scrollProgress)
const nextIndex = Math.min(currentIndex + 1, tabs.length - 1)
Expand All @@ -133,7 +133,7 @@ export const TabBar = forwardRef<ScrollView, TabBarProps>(
tabWidths[currentIndex] + (tabWidths[nextIndex] - tabWidths[currentIndex]) * progress

return {
transform: [{ translateX: xPosition }],
transform: [{ translateX: Math.max(xPosition, 0) }],
width,
backgroundColor: tabs[currentTab].activeColor || accentColor,
}
Expand Down

0 comments on commit e625ada

Please sign in to comment.