mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-03 22:48:25 +08:00
Fix measureInWindow when using Nodes
Summary: The results from measureInWindow were always wrong the first time it was called. This was due to the fact that the view in question was not actually a view yet, so the results were incorrect. This patch uses the existing measure functionality (which can measure virtual nodes) to measure the view, while modifying it to properly get the results relative to the window instead of relative to the root view. Reviewed By: sriramramani Differential Revision: D3501544
This commit is contained in:
@@ -182,6 +182,10 @@ public class FlatUIImplementation extends UIImplementation {
|
||||
|
||||
@Override
|
||||
public void measure(int reactTag, Callback callback) {
|
||||
measureHelper(reactTag, false, callback);
|
||||
}
|
||||
|
||||
private void measureHelper(int reactTag, boolean relativeToWindow, Callback callback) {
|
||||
FlatShadowNode node = (FlatShadowNode) resolveShadowNode(reactTag);
|
||||
if (node.mountsToView()) {
|
||||
mStateBuilder.ensureBackingViewIsCreated(node);
|
||||
@@ -216,6 +220,7 @@ public class FlatUIImplementation extends UIImplementation {
|
||||
yInParent / parentHeight,
|
||||
width / parentWidth,
|
||||
height / parentHeight,
|
||||
relativeToWindow,
|
||||
callback);
|
||||
}
|
||||
|
||||
@@ -235,8 +240,7 @@ public class FlatUIImplementation extends UIImplementation {
|
||||
|
||||
@Override
|
||||
public void measureInWindow(int reactTag, Callback callback) {
|
||||
ensureMountsToViewAndBackingViewIsCreated(reactTag);
|
||||
super.measureInWindow(reactTag, callback);
|
||||
measureHelper(reactTag, true, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user