Skip to content

Commit

Permalink
Fabric: UIManagerBinding::getRelativeLayoutMetrics
Browse files Browse the repository at this point in the history
Summary: Exposing the getRelativeLayoutMetrics method to JS.

Reviewed By: mdvacca

Differential Revision: D13036552

fbshipit-source-id: de825dfde8e64163168510aea1eda77370753b29
  • Loading branch information
shergin authored and facebook-github-bot committed Nov 28, 2018
1 parent 7b2e3f8 commit d594d5a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ReactCommon/fabric/uimanager/UIManagerBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit d594d5a

Please sign in to comment.