onLayout event.nativeEvent.layout.x value incorrect when container has transform scale
react 15.4.2 react-native-web 0.0.68 (running in Chrome 55.0.2883.87) react-native 0.40.0
rendering:
<View ref="container" style={{ flexDirection: 'row', width: WIDTH, transform: transform }}>
<Node ...... />
<Text onLayout={ this.onLayout }></Text>
</View>
WIDTH is a large value (10000) chosen to be larger than the content is ever going to be. <Node/> renders as a bunch of stuff. The <Text/> element is used so I can get the width of the stuff rendered by <Node/> (the reason for all this is so that I can measure the width and then adjust the transform to get <Node/> to just fill the parent <View/>).
transform is set like [ { scale: somescalevalue }, { translate: sometranslation } ]
With react native, the value of event.nativeEvent.layout.x in the call to this.onLayout is the width of <Node/> were there to be no scaling; with react-native-web it is the width when the scaling is applied. So in react native in this.onLayout I have:
let width = event.nativeEvent.layout.x ;
while in react native web I need:
let width = event.nativeEvent.layout.x / somescalevalue ;
In neither case do I need to take into account some translation.
Hope this makes sense Regards Mike
I believe the same applies to hight. Regards Mike