mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-10 18:05:26 +08:00
Fabric: UIManagerBinding::getRelativeLayoutMetrics
Summary: Exposing the getRelativeLayoutMetrics method to JS. Reviewed By: mdvacca Differential Revision: D13036552 fbshipit-source-id: de825dfde8e64163168510aea1eda77370753b29
This commit is contained in:
committed by
Facebook Github Bot
parent
7b2e3f8159
commit
d594d5a4e5
@@ -281,6 +281,29 @@ jsi::Value UIManagerBinding::get(
|
||||
});
|
||||
}
|
||||
|
||||
if (methodName == "getRelativeLayoutMetrics") {
|
||||
return jsi::Function::createFromHostFunction(
|
||||
runtime,
|
||||
name,
|
||||
2,
|
||||
[&uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
const jsi::Value &thisValue,
|
||||
const jsi::Value *arguments,
|
||||
size_t count) -> jsi::Value {
|
||||
auto layoutMetrics = uiManager.getRelativeLayoutMetrics(
|
||||
*shadowNodeFromValue(runtime, arguments[0]),
|
||||
shadowNodeFromValue(runtime, arguments[1]).get());
|
||||
auto frame = layoutMetrics.frame;
|
||||
auto result = jsi::Object(runtime);
|
||||
result.setProperty(runtime, "left", frame.origin.x);
|
||||
result.setProperty(runtime, "top", frame.origin.y);
|
||||
result.setProperty(runtime, "width", frame.size.width);
|
||||
result.setProperty(runtime, "height", frame.size.height);
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
return jsi::Value::undefined();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user