-
Notifications
You must be signed in to change notification settings - Fork 60
Closed
Description
The fast way to make completely round borders in React Native is to set a very high borderRadius like so:
const styles = StyleSheet.create({
card: {
backgroundColor: '#000',
height: 300,
borderRadius: 1000,
width: 100,
},
});
This technique have an interesting result used with react-native-shadow-2.
A failsafe to prevent something like this happening could be to limit the shadow calculation by the component's dimensions from the LayoutEvent Object using onLayout. The smallest value of either width or height should be used for the calculation.
Example of the calculation could look something like this:
// First get the smallest dimension of width or height
const smallestDims = e.layout.width <== e.layout.height ? e.layout.width : e.layout.height
// Second use the smallest dimension to calculate the failsafe shadow radius
const failsafeRadius = radius > smallestDims ? smallestDims / 2 : radius
Metadata
Metadata
Assignees
Labels
No labels