1

I need to retrieve the position on the screen of a TextInput from the onFocus event. I haven't found documentation about this, my problem is that I cannot find out the element from the event triggered on focus. Here the code:

_handleOnFocus(event) {        
console(event.nativeEvent.target.layout.y); // where is the y coordinate?
}

The callback is inserted here:

<TextInput onFocus={              
onFocus={event => {this._handleOnFocus(event);}}} ... />
bertonc96
  • 772
  • 2
  • 13
  • 24

1 Answers1

0

You can access it by event.target.offsetTop but consider that it will return offset from closest not static parent. If you need absolute offset, please refer to this question: Finding element's position relative to the document

Eugene Tsakh
  • 2,777
  • 2
  • 14
  • 27