diff --git a/docs/PROPSMETHODS.md b/docs/PROPSMETHODS.md index ca954f67..db05606a 100644 --- a/docs/PROPSMETHODS.md +++ b/docs/PROPSMETHODS.md @@ -268,6 +268,14 @@ Callback used when you press the overlay. | -------- | -------- | | function | No | +### `onLayout` + +Callback to subscribe to layout changes. Return the `LayoutRectangle` object from react-native. + +| Type | Required | +| -------------------------------------------------------------------------------------------- | -------- | +| function: (nativeEvent: { layout: { height: number, width: number, x: number, y: number } }) | No | +


diff --git a/src/index.tsx b/src/index.tsx index 9c3fe054..5d6be891 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -376,7 +376,11 @@ export class Modalize extends React.C }; private onContentViewLayout = ({ nativeEvent }: LayoutChangeEvent): void => { - const { adjustToContentHeight, disableScrollIfPossible } = this.props; + const { adjustToContentHeight, disableScrollIfPossible, onLayout } = this.props; + + if (onLayout) { + onLayout(nativeEvent); + } if (!adjustToContentHeight) { return; diff --git a/src/options.ts b/src/options.ts index b15bdfa6..7b7c7983 100644 --- a/src/options.ts +++ b/src/options.ts @@ -6,6 +6,7 @@ import { FlatListProps, SectionListProps, EasingFunction, + LayoutRectangle, } from 'react-native'; export interface ITimingProps { @@ -230,6 +231,11 @@ export interface IProps { * Callback used when you press the overlay. */ onOverlayPress?(): void; + + /** + * Callback used when you press the overlay. + */ + onLayout?(nativeEvent: { layout: LayoutRectangle }): void; } export interface IState {