IjzerenHein / react-navigation-shared-element

React Navigation bindings for react-native-shared-element 💫
https://github.com/IjzerenHein/react-native-shared-element
MIT License
1.27k stars 124 forks source link

Compatible with screens in different stacks? #135

Open jfbn opened 3 years ago

jfbn commented 3 years ago

I am looking to implement shared element transitions in our application.

I want to navigate from a screen in one stack, to a screen in another stack. The stacks are each in their own tab screen, like so:

Tab Navigator

I want to navigate from Screen 1 to Screen 2 using a shared element. Is this possible? I cannot find any mention of this use case or any other issues which could address the navigation between different stacks.

What are my options?

eikhunter commented 3 years ago

+1

fmtjava commented 3 years ago

+1

jfbn commented 3 years ago

I guess the answer is no for the time being. What a shame :(

thisisgit commented 3 years ago

Hi @jfbn, I'm not sure if you have already found the solution to that but here's the workaround (and a comment pointing to that solution)

Basically you need to have shared element stack as the parent of tab navigator, and the stacks in each tab screen should be shared element stack as well:

For those who are looking for ListScreen<>DetailScreen interaction, you may want to check this issue for reference.

jfbn commented 3 years ago

Hi @thisisgit, Thank you so much for tagging me in your comment. This sounds really great. I'm going to try and implement this during the week and will report back with an update.

IjzerenHein commented 3 years ago

So, in short, I think what you're saying here is that you want to transitions to happen when switching tabs (correct me if I'm wrong). And inside the tabs there are stack navigators. Switching (bottom/top) tabs usually does not cause an animation to run in react-navigation, so I'm not sure how you expect shared elements to run in that case.

Pietro-Putelli commented 2 years ago

Hi @jfbn, I'm not sure if you have already found the solution to that but here's the workaround (and a comment pointing to that solution)

Basically you need to have shared element stack as the parent of tab navigator, and the stacks in each tab screen should be shared element stack as well:

  • Shared Element Stack Navigator

    • Tab Navigator

    • Shared Element Stack Navigator

      • Screen 1 (with shared element)
    • Shared Element Stack Navigator

      • Screen 2 (with shared element)
    • Some other navigator

For those who are looking for ListScreen<>DetailScreen interaction, you may want to check this issue for reference.

In react navigation v.6 this solve the issue. Thank you.