Fix positioning
This commit is contained in:
@@ -26,6 +26,9 @@ export interface TabBarProps {
|
|||||||
dragState: SharedValue<'idle' | 'dragging' | 'settling'>
|
dragState: SharedValue<'idle' | 'dragging' | 'settling'>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ITEM_PADDING = 10
|
||||||
|
const CONTENT_PADDING = 6
|
||||||
|
|
||||||
export function TabBar({
|
export function TabBar({
|
||||||
testID,
|
testID,
|
||||||
selectedPage,
|
selectedPage,
|
||||||
@@ -59,7 +62,8 @@ export function TabBar({
|
|||||||
const progressToOffset = useCallback(
|
const progressToOffset = useCallback(
|
||||||
(progress: number) => {
|
(progress: number) => {
|
||||||
'worklet'
|
'worklet'
|
||||||
const offsetPerPage = contentSize.get() - containerSize.get()
|
const offsetPerPage =
|
||||||
|
contentSize.get() + 2 * CONTENT_PADDING - containerSize.get()
|
||||||
return (progress / (itemsLength - 1)) * offsetPerPage
|
return (progress / (itemsLength - 1)) * offsetPerPage
|
||||||
},
|
},
|
||||||
[itemsLength, contentSize, containerSize],
|
[itemsLength, contentSize, containerSize],
|
||||||
@@ -187,7 +191,9 @@ export function TabBar({
|
|||||||
scaleX: interpolate(
|
scaleX: interpolate(
|
||||||
dragProgress.get(),
|
dragProgress.get(),
|
||||||
layoutsValue.map((l, i) => i),
|
layoutsValue.map((l, i) => i),
|
||||||
layoutsValue.map(l => (l.width - 12) / contentSize.get()),
|
layoutsValue.map(
|
||||||
|
l => (l.width - ITEM_PADDING * 2) / contentSize.get(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -330,11 +336,11 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
contentContainer: {
|
contentContainer: {
|
||||||
backgroundColor: 'transparent',
|
backgroundColor: 'transparent',
|
||||||
paddingHorizontal: 6,
|
paddingHorizontal: CONTENT_PADDING,
|
||||||
},
|
},
|
||||||
item: {
|
item: {
|
||||||
paddingTop: 10,
|
paddingTop: 10,
|
||||||
paddingHorizontal: 10,
|
paddingHorizontal: ITEM_PADDING,
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
itemInner: {
|
itemInner: {
|
||||||
|
|||||||
Reference in New Issue
Block a user