Skip to content

Commit c919fd2

Browse files
committed
fix: don't disable tabbar animation when sceneAnimationEnabled is false
1 parent 8daede9 commit c919fd2

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

example/src/Examples/BottomNavigationExample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ export default class BottomNavigationExample extends React.Component<
7575
<BottomNavigation
7676
navigationState={this.state}
7777
onIndexChange={index => this.setState({ index })}
78-
// @ts-ignore
7978
renderScene={BottomNavigation.SceneMap({
8079
album: PhotoGallery,
8180
library: PhotoGallery,
8281
favorites: PhotoGallery,
8382
purchased: PhotoGallery,
8483
})}
84+
sceneAnimationEnabled={false}
8585
/>
8686
);
8787
}

src/components/BottomNavigation.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ class BottomNavigation extends React.Component<Props, State> {
481481

482482
private animateToCurrentIndex = () => {
483483
const shifting = this.isShifting();
484-
const { sceneAnimationEnabled, navigationState } = this.props;
484+
const { navigationState } = this.props;
485485
const { routes, index } = navigationState;
486486

487487
// Reset the ripple to avoid glitch if it's currently animating
@@ -496,7 +496,7 @@ class BottomNavigation extends React.Component<Props, State> {
496496
...routes.map((_, i) =>
497497
Animated.timing(this.state.tabs[i], {
498498
toValue: i === index ? 1 : 0,
499-
duration: shifting && sceneAnimationEnabled !== false ? 150 : 0,
499+
duration: shifting ? 150 : 0,
500500
useNativeDriver: true,
501501
})
502502
),
@@ -585,6 +585,7 @@ class BottomNavigation extends React.Component<Props, State> {
585585
labeled,
586586
style,
587587
theme,
588+
sceneAnimationEnabled,
588589
} = this.props;
589590

590591
const {
@@ -655,15 +656,16 @@ class BottomNavigation extends React.Component<Props, State> {
655656
// Don't render a screen if we've never navigated to it
656657
return null;
657658
}
659+
const focused = navigationState.index === index;
660+
661+
const opacity =
662+
sceneAnimationEnabled !== false ? tabs[index] : focused ? 1 : 0;
658663

659-
const opacity = tabs[index];
660664
const top = offsets[index].interpolate({
661665
inputRange: [0, 1],
662666
outputRange: [0, FAR_FAR_AWAY],
663667
});
664668

665-
const focused = navigationState.index === index;
666-
667669
return (
668670
<Animated.View
669671
key={route.key}

0 commit comments

Comments
 (0)