IjzerenHein / IjzerenHein/react-navigation-shared-element
shared element transition offset to left
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 125
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I have a problem where the shared element is determined correctly, so the ids are correct but the animation has a huge offset to the left. I know that the IDs are correct because you can see how the image will be transformed to the correct scale, but with offset, you see below.
Unfortunately I do not know, why this happens.

My current setup (minified) is the following:
- Root (SharedElementStackNavigator)
-> TopTabNavigator
-> RestaurantPreview
- TopTabNavigator
-> ...
-> RestaurantList
-> ...
- RestaurantList (SharedElementStackNavigator) (because the RestaurantListItem needs to be determined as a shared element)
-> Restaurant
- RestaurantPreview is just a normal screen
Here's my setup in code:
**TopTabNavigator**
```
const MainTab = createMaterialTopTabNavigator(
{
Home: {
screen: HomeScreen,
},
RestaurantList: {
screen: RestaurantListScreen,
},
Food: {
screen: FoodScreen,
},
Favorites: {
screen: FavoritesScreen,
},
Menu: {
screen: Settings,
},
},
{
...
}
);
```
**Parent**
```
const StackNavigator = createSharedElementStackNavigator(
{
MainTab,
RestaurantPreview,
},
{initialRouteName: 'MainTab', headerMode: 'screen', mode:"modal"},
{
debug: true,
name: 'SharedElementsStack',
},
);
export default StackNavigator;
```
**RestaurantListScreen:**
```
export default createSharedElementStackNavigator(
{
Home,
Maps,
},
{
initialRouteName: 'Home',
headerMode: 'screen',
},
{name: 'RestaurantStack', debug: true},
);
```
**in RestaurantPreview-Screen:**
```
static sharedElements = (navigation, otherNavigation, showing) => {
return [
{
id: `image.${navigation.getParam('item').key}`,
},
];
};
render() {
...
...
}
```
**In RestaurantList**
```
render(){
...
{
return (
{
navigation.navigate('RestaurantPreview', {item: item});
}}
style={{width: '100%', height: '100%'}}>
...
}
```
Any ideas?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the reported offset with the Root SharedElementStackNavigator, TopTabNavigator, RestaurantListScreen, and RestaurantPreview setup shown in the issue. Inspect the sharedElements definitions and the two SharedElement render paths; done means the image transition preserves the correct position as well as scale.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100