Skip to content
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

Shared Element animation using showModal and dismiss gesture (like instagram story) #7496

Closed
Pietro-Putelli opened this issue Apr 2, 2022 · 1 comment

Comments

@Pietro-Putelli
Copy link

Hi, I'm trying to create an instagram story like screen, when you press the story the sharedElement transition is triggered and then in StoryScreen, if you perform the dismiss gesture, the screen will disappear with the sharedElement transition as well.

I'd like to achieve a transparent background, in order to scale the detail screen and see the under screen before releasing the gesture and dismissing it, so the best solution, and the only one that allow transparent background screens, is using showModal with the following options, as show in the library playground folder:

  Navigation.showModal({
      component: {
        name: "StoriesScreen",
        options: {
          animations: {
            showModal: {
              alpha: {
                from: 0,
                to: 1,
                duration: SET_DURATION,
              },
              sharedElementTransitions: [
                {
                  fromId: `image.1.from`,
                  toId: `image.1.to`,
                  duration: SET_DURATION,
                  interpolation: { type: "spring", ...SPRING_CONFIG },
                },
              ],
            },
            pop: {
              alpha: {
                from: 1,
                to: 0,
                duration: SET_DURATION,
              },
              sharedElementTransitions: [
                {
                  fromId: `image.1.to`,
                  toId: `image.1.from`,
                  duration: SET_DURATION,
                  interpolation: { type: "spring", ...SPRING_CONFIG },
                },
              ],
            },
          },
        },
      },
    });

/* From component */

      <TouchableOpacity onPress={onPress} style={SIZE}>
        <Image
          nativeID="image.1.from"
          style={{ flex: 1 }}
          source={{ uri: A }}
        />
      </TouchableOpacity>

/* Destination component */

      <Image
        nativeID="image.1.to"
        style={{ flex: 1 }}
        source={{
          uri: "https://cdn.we-wealth.com/-/media/Images/social/porsche-356-quando-il-fascino-speedster-conquisto-lamerica.png?rev=9c55b0db85954d18bf4b818784682d26&modified=20201126232413",
        }}
      />

(Invoke Navigation.dismissModal(componentId) to dismiss through gesture.

But here's the result:

RPReplay_Final1648886714.MP4

Then if I instead us push, the sharedElement transition works, but I can't achieve the transparent background.
So since this #6647 suggests that the sharedElement is supported by modals too, there's and error in my code.

Thank you really much

@github-actions
Copy link

github-actions bot commented Apr 2, 2022

We use the issue tracker exclusively for bug reports and feature requests.
This issue appears to be a general usage or support question.
Instead, please ask a question on Stack Overflow with the wix-react-native-navigation tag or on Discord.

@github-actions github-actions bot closed this as completed Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant