Skip to content
This repository was archived by the owner on Nov 27, 2022. It is now read-only.

Commit 074d593

Browse files
committed
refactor: change prop name
1 parent dfd4dbf commit 074d593

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,9 @@ Style to apply to the view wrapping each screen. You can pass this to override s
335335

336336
Style to apply to the tab view container.
337337

338-
### `disableChangeTabAnimation`
338+
### `animationEnabled`
339339

340-
Boolean indicating whether to disable the change tab animation.
340+
Enables animation when changing tab. By default it's true.
341341

342342
### `TabBar`
343343

src/PagerViewAdapter.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default function PagerViewAdapter<T extends Route>({
4141
onSwipeEnd,
4242
children,
4343
style,
44-
disableChangeTabAnimation,
44+
animationEnabled,
4545
...rest
4646
}: Props<T>) {
4747
const { index } = navigationState;
@@ -64,11 +64,11 @@ export default function PagerViewAdapter<T extends Route>({
6464
(route: { key: string }) => route.key === key
6565
);
6666

67-
if (disableChangeTabAnimation) {
67+
if (animationEnabled) {
68+
pagerRef.current?.setPage(index);
69+
} else {
6870
pagerRef.current?.setPageWithoutAnimation(index);
6971
position.setValue(index);
70-
} else {
71-
pagerRef.current?.setPage(index);
7272
}
7373
// eslint-disable-next-line react-hooks/exhaustive-deps
7474
}, []);
@@ -79,11 +79,11 @@ export default function PagerViewAdapter<T extends Route>({
7979
}
8080

8181
if (indexRef.current !== index) {
82-
if (disableChangeTabAnimation) {
82+
if (animationEnabled) {
83+
pagerRef.current?.setPage(index);
84+
} else {
8385
pagerRef.current?.setPageWithoutAnimation(index);
8486
position.setValue(index);
85-
} else {
86-
pagerRef.current?.setPage(index);
8787
}
8888
}
8989
// eslint-disable-next-line react-hooks/exhaustive-deps

src/TabView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default function TabView<T extends Route>({
4949
style,
5050
swipeEnabled = true,
5151
tabBarPosition = 'top',
52-
disableChangeTabAnimation,
52+
animationEnabled = true,
5353
}: Props<T>) {
5454
const [layout, setLayout] = React.useState({
5555
width: 0,
@@ -85,7 +85,7 @@ export default function TabView<T extends Route>({
8585
onSwipeStart={onSwipeStart}
8686
onSwipeEnd={onSwipeEnd}
8787
onIndexChange={jumpToIndex}
88-
disableChangeTabAnimation={disableChangeTabAnimation}
88+
animationEnabled={animationEnabled}
8989
>
9090
{({ position, render, addEnterListener, jumpTo }) => {
9191
// All of the props here must not change between re-renders

src/types.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ export type PagerProps = Omit<
5555
swipeEnabled?: boolean;
5656
onSwipeStart?: () => void;
5757
onSwipeEnd?: () => void;
58-
disableChangeTabAnimation?: boolean;
58+
animationEnabled?: boolean;
5959
};

0 commit comments

Comments
 (0)