with react native.
I can get the position and size with onLayout
, but I want to get the absolute position of a view relative to the screen
please! t
You might want to use the "onTouchStart". it Determines the location on screen from pageX, pageY of the given view and returns the values.
<View
onTouchStart={(e) => {console.log('touchMove', e.nativeEvent.pageY)}}
>
a better example can be found here: https://facebook.github.io/react-native/docs/panresponder.html
you can use measure(callback) it Determines the location on screen, width, and height of the given view and returns the values via an async callback.
a better example can be found here React Native: Getting the position of an element
<View
ref={(ref) => { this.marker = ref }}
onLayout={({nativeEvent}) => {
if (this.marker) {
this.marker.measure((x, y, width, height, pageX, pageY) => {
console.log(x, y, width, height, pageX, pageY);
})
}
}}
>