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 with placement shifting with 'modal' #264

Open
ejkkan opened this issue Feb 11, 2023 · 4 comments
Open

Shared element with placement shifting with 'modal' #264

ejkkan opened this issue Feb 11, 2023 · 4 comments

Comments

@ejkkan
Copy link

ejkkan commented Feb 11, 2023

Hey, I'm using shared elements between multiple different screens. But If I try to use shared elements pushing in to a modal type screen('presentation: 'modal'), the transition between screens the animation is a bit off and then skips into the correct position.
Please see video.

shared.transition.bug.mov
//Stack

<Stack.Navigator
      screenOptions={{
        headerShown: false,
        gestureEnabled: true,
      }}
    >

      <Stack.Screen
        name="Charity"
        sharedElements={(route, otherRoute, showing) => {
          return [
            {
              id: `sharedbutton`,
              animation: 'fade',
            },
          ];
        }}
        component={Charity}
      />
      <Stack.Screen
        sharedElements={() => {
          return [
            {
              id: `sharedbutton`,
              animation: 'fade',
              resize: 'auto',
            },
          ];
        }}
        options={{
          headerShown: false,
          animationEnabled: true,
          presentation:'modal'
        }}
        name="Checkout"
        component={Checkout}
      />
    </Stack.Navigator>
//Component 1

export const Checkout = ({}: Props) => {
  return (
    <SafeAreaView className="flex-1 p-4 bg-[#313642]">
    ... more code
      <View className="absolute right-8 bottom-8">
        <SharedElement id="sharedbutton">
          <GuideButton type="pay" onPress={submit} />
        </SharedElement>
      </View>
    </SafeAreaView>
  );
};
//Component 2

export const Checkout = ({}: Props) => {
  return (
    <SafeAreaView className="flex-1 p-4 bg-[#313642]">
    ... more code
      <View className="flex">
        <SharedElement id="sharedbutton">
          <GuideButton type="pay" onPress={submit} />
        </SharedElement>
      </View>
    </SafeAreaView>
  );
};
@ejkkan
Copy link
Author

ejkkan commented Feb 11, 2023

Solved by applying this:
#261 (comment)

But maybe it should be included in the lib?

@ejkkan ejkkan closed this as completed Feb 12, 2023
@ejkkan ejkkan reopened this Feb 15, 2023
@ejkkan
Copy link
Author

ejkkan commented Feb 15, 2023

Reopening since the found solution is for a fade transition and not the regular modal transition.

@joaquinperezlopez
Copy link

@ejkkan I have the same problem, did you find any workaround or alternative?

@p-syche
Copy link
Collaborator

p-syche commented Mar 31, 2023

Hello @ejkkan, hello @joaquinperezlopez ,

I'm sorry you're facing this UI issue. I see you saw the comment about adding ModalFadeTransition and you said you don't need a fade but a regular one.

Going ove the @react-navigation source I found there are other modal-related transitions: https://github.com/react-navigation/react-navigation/blob/main/packages/stack/src/TransitionConfigs/TransitionPresets.tsx#L135

Can you try the following solution:

options={{ presentation: 'transparentModal', ...DefaultTransition }}

(import or clone ModalFadeTransition from @react-navigation/stack package)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants