@@ -620,7 +620,7 @@ jsi::Value UIManagerBinding::get(
620
620
*shadowNodeFromValue (runtime, arguments[0 ]),
621
621
nullptr ,
622
622
{/* .includeTransform = */ true ,
623
- /* includeViewportOffset = */ true });
623
+ /* . includeViewportOffset = */ true });
624
624
625
625
auto onSuccessFunction =
626
626
arguments[1 ].getObject (runtime).getFunction (runtime);
@@ -641,6 +641,40 @@ jsi::Value UIManagerBinding::get(
641
641
});
642
642
}
643
643
644
+ if (methodName == " getBoundingClientRect" ) {
645
+ // This is similar to `measureInWindow`, except it's explicitly synchronous
646
+ // (returns the result instead of passing it to a callback).
647
+ // The behavior is similar to `Element.prototype.getBoundingClientRect` from
648
+ // Web.
649
+ return jsi::Function::createFromHostFunction (
650
+ runtime,
651
+ name,
652
+ 1 ,
653
+ [uiManager](
654
+ jsi::Runtime &runtime,
655
+ jsi::Value const & /* thisValue*/ ,
656
+ jsi::Value const *arguments,
657
+ size_t /* count*/ ) noexcept -> jsi::Value {
658
+ auto layoutMetrics = uiManager->getRelativeLayoutMetrics (
659
+ *shadowNodeFromValue (runtime, arguments[0 ]),
660
+ nullptr ,
661
+ {/* .includeTransform = */ true ,
662
+ /* .includeViewportOffset = */ true });
663
+
664
+ if (layoutMetrics == EmptyLayoutMetrics) {
665
+ return jsi::Value::undefined ();
666
+ }
667
+
668
+ auto frame = layoutMetrics.frame ;
669
+ return jsi::Array::createWithElements (
670
+ runtime,
671
+ jsi::Value{runtime, (double )frame.origin .x },
672
+ jsi::Value{runtime, (double )frame.origin .y },
673
+ jsi::Value{runtime, (double )frame.size .width },
674
+ jsi::Value{runtime, (double )frame.size .height });
675
+ });
676
+ }
677
+
644
678
if (methodName == " sendAccessibilityEvent" ) {
645
679
return jsi::Function::createFromHostFunction (
646
680
runtime,
0 commit comments