Can onLayout also provide the page position, like measure does?
See original GitHub issueDescription
The onLayout
callback now provides in its layout data the same information as the measure
(NativeMethodsMixin) callback does, except for the missing absolute page position. Is there a technical reason for this, or can these 2 values also be included in the onLayout
data?
I’m now calling measure
(i.e. triggering the callback) in the onLayout
callback, in order to know when measure(
) can provide (update) information, but this seems to be double work.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
React Native: Getting the position of an element - Stack Overflow
React Native provides a .measure(...) method which takes a callback and calls it with the offsets and width/height of a component: myComponent.measure( (fx ......
Read more >#PerfMatters introduction to custom ViewGroups to improve ...
In this article I'll try to demystify onMeasure and onLayout methods in ViewGroup which you can use to measure and position all the...
Read more >How Android Draws Views
It is requested to measure and draw the layout tree. Drawing is handled by walking the tree and rendering each View that intersects...
Read more >Stack Navigator | React Navigation
Stack Navigator provides a way for your app to transition between screens where each new screen is placed on top of a stack....
Read more >CodeMirror System Guide
CodeMirror is set up as a collection of separate modules that, together, provide a full-featured text and code editor. On the bright side,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So, there’s a workaround for this, but it’s really awkward – you need to save a child view as a ref, and then use that ref in a callback in another callback in onLayout.
There are legitimate use cases for absolute page positioning, one of which is drag/drop; if you want to know if one component has been dropped onto another when the two don’t share a common immediate parent.
If there’s no technical limitation preventing this from being surfaced as a param to onLayout (or on another event handler) then could we re-open this issue?
the workaround looks like this, fwiw: