nav: Don't show a transition animation between 'loading' and 'main'.#4260
Conversation
|
LGTM, thanks! Please merge at will.
I think there are a couple of exceptions but this is fine. In particular:
So in short if you launch the app and don't have an active, logged-in account, we will have a navigation from |
New in the recent React Navigation upgrades to v3 and v4, there's now a transition animation when the loading screen exits. We don't want to prolong the effect of the loading screen [1], so, get rid of that exit animation. Most accurately, we want to target the exit of the loading screen and disable the animation there. But it seems that the `animationEnabled` switch in `navigationOptions` operates on the *entrance* of particular screen; I haven't found a similar option for the *exit* of a particular screen. A good workaround, to the extent that it's practical, would be to tell all screens to disable their entrance animations if and only if they're being reached directly from the loading screen. The only reasonably simple way I can think of to implement this would be to set `defaultNavigationOptions` to a function instead of an object [2] and use that function's inputs to conditionalize on the identity of the route being navigated *from*, i.e., the previous route. Unfortunately, that doesn't seem possible; the `navigation` object is the most likely-looking of those inputs, and logging shows that it doesn't have data about the previous route, only the current route (in `navigation.state`). So, we use a heuristic: always cancel the entrance animation of the main-tabs screen. This is supported by the following observations (but naturally there may be edge cases I haven't considered): - An extremely frequent and high-visibility action is to navigate from the loading screen to the main-tabs screen. - We don't generally navigate from the loading screen to anywhere other than the main-tabs screen. - We don't generally navigate to the main-tabs screen from anywhere other than the loading screen. [1] zulip#4249 (review) [2] The best link I've found for this is https://reactnavigation.org/docs/4.x/headers/#using-params-in-the-title.
9e43b3f to
78e3e81
Compare
A followup to #4249; see #4249 (review).
New in the recent React Navigation upgrades to v3 and v4, there's
now a transition animation when the loading screen exits. We don't
want to prolong the effect of the loading screen [1], so, get rid of
that exit animation.
Most accurately, we want to target the exit of the loading screen
and disable the animation there. But it seems that the
animationEnabledswitch innavigationOptionsoperates on theentrance of particular screen; I haven't found a similar option
for the exit of a particular screen.
A good workaround, to the extent that it's practical, would be to
tell all screens to disable their entrance animations if and only if
they're being reached directly from the loading screen. The only
reasonably simple way I can think of to implement this would be to
set
defaultNavigationOptionsto a function instead of anobject [2] and use that function's inputs to conditionalize on the
identity of the route being navigated from, i.e., the previous
route. Unfortunately, that doesn't seem possible; the
navigationobject is the most likely-looking of those inputs, and logging shows
that it doesn't have data about the previous route, only the current
route (in
navigation.state).So, we use a heuristic: always cancel the entrance animation of the
main-tabs screen. This is supported by the following observations
(but naturally there may be edge cases I haven't considered):
from the loading screen to the main-tabs screen.
other than the main-tabs navigator.
anywhere other than the loading screen.
[1] #4249 (review)
[2] The best link I've found for this is
https://reactnavigation.org/docs/4.x/headers/#using-params-in-the-title.