From 44a579f3e0fc73b2ef7c4b28875d6c4027d071b4 Mon Sep 17 00:00:00 2001 From: Libin Lu Date: Wed, 5 Apr 2017 14:15:43 -0400 Subject: [PATCH 1/2] add measure function into ui manager --- types/react-native/index.d.ts | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index e282f17191..f907e13481 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -7156,6 +7156,57 @@ export interface UIManagerStatic { quality ?: number, } ) => Promise + + /** + * Determines the location on screen, width, and height of the given view and + * returns the values via an async callback. If successful, the callback will + * be called with the following arguments: + * + * - x + * - y + * - width + * - height + * - pageX + * - pageY + * + * Note that these measurements are not available until after the rendering + * has been completed in native. If you need the measurements as soon as + * possible, consider using the [`onLayout` + * prop](docs/view.html#onlayout) instead. + */ + measure(node: number, callback: MeasureOnSuccessCallback): void; + + /** + * Determines the location of the given view in the window and returns the + * values via an async callback. If the React root view is embedded in + * another native view, this will give you the absolute coordinates. If + * successful, the callback will be called with the following + * arguments: + * + * - x + * - y + * - width + * - height + * + * Note that these measurements are not available until after the rendering + * has been completed in native. + */ + measureInWindow(node: number, callback: MeasureInWindowOnSuccessCallback): void; + + /** + * Like [`measure()`](#measure), but measures the view relative an ancestor, + * specified as `relativeToNativeNode`. This means that the returned x, y + * are relative to the origin x, y of the ancestor view. + * + * As always, to obtain a native node handle for a component, you can use + * `React.findNodeHandle(component)`. + */ + measureLayout( + node: number, + relativeToNativeNode: number, + onSuccess: MeasureLayoutOnSuccessCallback, + onFail: () => void /* currently unused */ + ): void; } export interface SwitchPropertiesIOS extends ViewProperties, React.Props { From 1bf9a4e75f728e3164a6a841ecd8cef986699f19 Mon Sep 17 00:00:00 2001 From: Libin Lu Date: Wed, 5 Apr 2017 16:54:07 -0400 Subject: [PATCH 2/2] Update index.d.ts --- types/react-native/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index f907e13481..677cd6bb26 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -7156,7 +7156,7 @@ export interface UIManagerStatic { quality ?: number, } ) => Promise - + /** * Determines the location on screen, width, and height of the given view and * returns the values via an async callback. If successful, the callback will @@ -7204,8 +7204,8 @@ export interface UIManagerStatic { measureLayout( node: number, relativeToNativeNode: number, - onSuccess: MeasureLayoutOnSuccessCallback, - onFail: () => void /* currently unused */ + onFail: () => void, /* currently unused */ + onSuccess: MeasureLayoutOnSuccessCallback ): void; }