IjzerenHein / IjzerenHein/react-navigation-shared-element
[v5] borderRadius not animating when going to another screen, it animates only on back
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 125
- PR merge metrics
- No merged PRs in 30d
Description
It's my first time using this lib, so I don't know if it is a regression or if there's something wrong with my code .
## Description
I'm trying to transition from:
1) Screen with a square-element with `borderRadius: 16`; to
2) Screen with a circle
And the problems are:
1) The default Android screen transition is shown (from bottom to top)
2) `borderRadius` animate only when going back from the second screen
3) The `background-color` didn't animate either, even though my real app doesn't need it
| My app | Simple repro I created |
| -------- | ------------------------- |
|  |  |
## Dependencies
```json
{
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/native": "^5.7.6",
"@react-navigation/stack": "^5.9.3",
"react": "16.13.1",
"react-native": "0.63.3",
"react-native-gesture-handler": "^1.8.0",
"react-native-reanimated": "^1.13.1",
"react-native-safe-area-context": "^3.1.8",
"react-native-screens": "^2.11.0",
"react-native-shared-element": "^0.7.0",
"react-navigation-shared-element": "^5.0.0-alpha1"
}
```
## Reproducible demo
[Repro repository here.](https://github.com/Rafatcb/shared-element-border-radius-bug)
**App.js**
```javascript
import 'react-native-gesture-handler';
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createSharedElementStackNavigator } from 'react-navigation-shared-element';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { First } from './screens/First';
import { Second } from './screens/Second';
const AppStack = createSharedElementStackNavigator();
export default () => {
return (
);
};
```
**screens/First.js**
```javascript
import React from 'react';
import { Pressable, StyleSheet, Text, View } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { SharedElement } from 'react-navigation-shared-element';
export const First = ({ navigation }) => {
function goToSecond() {
navigation.navigate('Second');
}
return (
Navigate
);
};
const styles = StyleSheet.create({
button: {
alignSelf: 'center',
borderRadius: 16,
backgroundColor: '#fafafa',
padding: 16,
},
container: {
alignItems: 'center',
justifyContent: 'center',
flex: 1,
},
view: {
backgroundColor: '#000',
borderRadius: 16,
height: 300,
justifyContent: 'center',
width: 300,
},
});
```
**screens/Second.js**
```javascript
import React from 'react';
import { StyleSheet, View } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { SharedElement } from 'react-navigation-shared-element';
const Second = () => {
return (
);
};
const sharedElements = () => {
return ['enter'];
};
Second.sharedElements = sharedElements;
const styles = StyleSheet.create({
container: {
alignItems: 'center',
flex: 1,
justifyContent: 'center',
},
circle: {
backgroundColor: '#6f42c1',
borderRadius: 500,
height: 100,
width: 100,
},
});
export { Second };
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked reproducible demo, reading App.js, screens/First.js, and screens/Second.js alongside the listed React Navigation and shared-element dependencies. Compare forward and back transitions using the repro; done means the shared element's borderRadius and background color animate when navigating to the second screen without the unwanted default transition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native, typescript
- Domain
- frontend, mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100