react-native-gesture-handler icon indicating copy to clipboard operation
react-native-gesture-handler copied to clipboard

Absolutely positioned Touchable Opacity isn't correctly positioned when in centrally aligned container

Open matt-dalton opened this issue 4 years ago • 0 comments

If you position a TouchableOpacity like this:

<View style={{ position: 'relative', height: 300, backgroundColor: 'red' }} >
          <TouchableOpacity
              style={{
                    position: 'absolute',
                    right: 0
              }}
          >
                        <View style={{ height:50, width: 50, backgroundColor: "green"}}  />
           </TouchableOpacity>
</V>

the Touchable aligns correctly to the right: Screenshot 2020-08-04 at 18 28 11

However if I add alignItems to the container, the Touchable aligns in the wrong place:

<View
          style={{
                        position: 'relative',
                        height: 300,
                        backgroundColor: 'red',
                        alignItems: 'center'
           }}
         >
                    <TouchableOpacity
                        style={{
                            position: 'absolute',
                            right: 0
                        }}
                    >
                        <View style={{ height: 50, width: 50, backgroundColor: 'green' }} />
                    </TouchableOpacity>
</View>

Screenshot 2020-08-04 at 18 34 55

I'm on version 1.7.0. If I swap with the react-native TouchableOpacity it positions correctly

matt-dalton avatar Aug 04 '20 17:08 matt-dalton