Skip to content

Commit d594d5a

Browse files
sherginfacebook-github-bot
authored andcommitted
Fabric: UIManagerBinding::getRelativeLayoutMetrics
Summary: Exposing the getRelativeLayoutMetrics method to JS. Reviewed By: mdvacca Differential Revision: D13036552 fbshipit-source-id: de825dfde8e64163168510aea1eda77370753b29
1 parent 7b2e3f8 commit d594d5a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

ReactCommon/fabric/uimanager/UIManagerBinding.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,29 @@ jsi::Value UIManagerBinding::get(
281281
});
282282
}
283283

284+
if (methodName == "getRelativeLayoutMetrics") {
285+
return jsi::Function::createFromHostFunction(
286+
runtime,
287+
name,
288+
2,
289+
[&uiManager](
290+
jsi::Runtime &runtime,
291+
const jsi::Value &thisValue,
292+
const jsi::Value *arguments,
293+
size_t count) -> jsi::Value {
294+
auto layoutMetrics = uiManager.getRelativeLayoutMetrics(
295+
*shadowNodeFromValue(runtime, arguments[0]),
296+
shadowNodeFromValue(runtime, arguments[1]).get());
297+
auto frame = layoutMetrics.frame;
298+
auto result = jsi::Object(runtime);
299+
result.setProperty(runtime, "left", frame.origin.x);
300+
result.setProperty(runtime, "top", frame.origin.y);
301+
result.setProperty(runtime, "width", frame.size.width);
302+
result.setProperty(runtime, "height", frame.size.height);
303+
return result;
304+
});
305+
}
306+
284307
return jsi::Value::undefined();
285308
}
286309

0 commit comments

Comments
 (0)