-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: force bottom navigation animation completion #4820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: force bottom navigation animation completion #4820
Conversation
|
Hey @chrisbarless, thank you for your pull request 🤗. The documentation from this branch can be viewed here. |
c6ec1cd to
866eeba
Compare
|
When shifting is set to true, the tab animation works as expected, the icon shifts up and the transition animates smoothly (slide/fade). So your fix solves part of the problem. However, with shifting set to false, the animation is now instant with no horizontal transition, whereas before the React Native update it used to animate horizontally (without the icon shifting up). Ideally, I’d like the horizontal animation to still work even when shifting is false, just without the icon moving up. |
On second look, I think you might be right. I'll keep working on it |
866eeba to
276f258
Compare
|
This approach seems to work better @CatLover01, want to have a look and let me know what you think? |
The code looks good! I just tested it and it works perfectly on my side for non-shifting. Thanks! |
| : active.interpolate({ | ||
| inputRange: [0, 1], | ||
| outputRange: [0, 1], | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Bug
The outline scale animation has a visual discontinuity when a tab becomes focused. The scale abruptly jumps from 0 to 0.5 at the start of the transition, instead of animating smoothly from 0, creating a jarring visual effect. This happens because the focused state changes instantly, altering the outlineScale interpolation range before the active animation begins.
Problem
In React Native 0.80+, the Material Design 3 pill indicator in BottomNavigation.Bar exhibits several animation issues:
shiftingpropThese issues are specific to React Native 0.80+ and are caused by changes in how the native animation driver handles
concurrent animations and mount behavior.
Root Cause
The Animated API's native driver in RN 0.80+ has two problems:
completion frames, leaving animated values in incomplete states
properly sync state, resulting in orphaned animations
The legacy workaround from RN 0.57 (removed in this PR) exacerbates these issues rather than solving them.
Solution
This PR implements a fix with several layers of protection:
The pill indicator was only rendered when
focused === true, causing instant appearance/disappearance instead of smooth animations. Additionally, theoutlineScaleinterpolation for unfocused tabs was inverted, making unfocused pills appear at full width.Original Code:
Fixed Code:
scaleXanimation to work on both enter and exitactive = 0(unfocused),scaleX = 0(invisible)activeanimates from 1 → 0, causingscaleXto smoothly shrink from 1 → 0activeanimates from 0 → 1, causingscaleXto smoothly grow from 0.5 → 1Testing
Tested on:
Scenarios tested:
Results:
Note
Ensures bottom navigation animations complete reliably, skip mount animation, gracefully cancel/restart during rapid switches, and always render the V3 pill for smooth enter/exit.
stopAnimation()+setValue()on completion; rAF fallback for interrupted runs.outlineScalefor unfocused state to enable smooth shrink/grow transitions.useEffect.Written by Cursor Bugbot for commit 3d358b8. This will update automatically on new commits. Configure here.