Skip to content
This repository was archived by the owner on Nov 27, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ Style to apply to the view wrapping each screen. You can pass this to override s

Style to apply to the tab view container.

### `disableChangeTabAnimation`

Boolean indicating whether to disable the change tab animation.

### `TabBar`

Material design themed tab bar. To customize the tab bar, you'd need to use the `renderTabBar` prop of `TabView` to render the `TabBar` and pass additional props.
Expand Down
17 changes: 15 additions & 2 deletions src/PagerViewAdapter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default function PagerViewAdapter<T extends Route>({
onSwipeEnd,
children,
style,
disableChangeTabAnimation,
...rest
}: Props<T>) {
const { index } = navigationState;
Expand All @@ -63,7 +64,13 @@ export default function PagerViewAdapter<T extends Route>({
(route: { key: string }) => route.key === key
);

pagerRef.current?.setPage(index);
if (disableChangeTabAnimation) {
pagerRef.current?.setPageWithoutAnimation(index);
position.setValue(index);
} else {
pagerRef.current?.setPage(index);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

React.useEffect(() => {
Expand All @@ -72,8 +79,14 @@ export default function PagerViewAdapter<T extends Route>({
}

if (indexRef.current !== index) {
pagerRef.current?.setPage(index);
if (disableChangeTabAnimation) {
pagerRef.current?.setPageWithoutAnimation(index);
position.setValue(index);
} else {
pagerRef.current?.setPage(index);
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [keyboardDismissMode, index]);

const onPageScrollStateChanged = (
Expand Down
2 changes: 2 additions & 0 deletions src/TabView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default function TabView<T extends Route>({
style,
swipeEnabled = true,
tabBarPosition = 'top',
disableChangeTabAnimation,
}: Props<T>) {
const [layout, setLayout] = React.useState({
width: 0,
Expand Down Expand Up @@ -84,6 +85,7 @@ export default function TabView<T extends Route>({
onSwipeStart={onSwipeStart}
onSwipeEnd={onSwipeEnd}
onIndexChange={jumpToIndex}
disableChangeTabAnimation={disableChangeTabAnimation}
>
{({ position, render, addEnterListener, jumpTo }) => {
// All of the props here must not change between re-renders
Expand Down
1 change: 1 addition & 0 deletions src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ export type PagerProps = Omit<
swipeEnabled?: boolean;
onSwipeStart?: () => void;
onSwipeEnd?: () => void;
disableChangeTabAnimation?: boolean;
};