diff --git a/src/index.tsx b/src/index.tsx index a07d9311..51e01384 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -144,7 +144,6 @@ export class Modalize extends React.C keyboardToggle: false, keyboardHeight: 0, disableScroll: props.alwaysOpen ? true : undefined, - adjust: props.adjustToContentHeight, }; this.beginScrollY.addListener(({ value }) => (this.beginScrollYValue = value)); @@ -168,7 +167,6 @@ export class Modalize extends React.C if (nextAdjust !== adjustToContentHeight) { this.setState({ modalHeight: nextAdjust ? undefined : this.initialComputedModalHeight, - adjust: nextAdjust, }); } } @@ -189,7 +187,7 @@ export class Modalize extends React.C this.onAnimateOpen(alwaysOpen, dest); }; - public close = (dest: TClose = 'default'): void => { + public close = (dest?: TClose): void => { const { onClose } = this.props; if (onClose) { @@ -201,10 +199,14 @@ export class Modalize extends React.C public scrollTo = (...args: Parameters): void => { if (this.contentView.current) { - (this.contentView.current as any) - .getNode() - .getScrollResponder() - .scrollTo(...args); + const ref = (this.contentView.current as any); + + // since RN 0.62 the getNode call has been deprecated + const scrollResponder = ref.getScrollResponder + ? ref.getScrollResponder() + : ref.getNode().getScrollResponder(); + + scrollResponder.scrollTo(...args); } }; @@ -605,7 +607,7 @@ export class Modalize extends React.C const diff = Math.abs(translationY / (this.initialComputedModalHeight - offset)); const y = translationY < 0 ? diff : 1 - diff; - let value; + let value: number; if (this.modalPosition === 'initial' && translationY > 0) { value = 0; @@ -717,8 +719,7 @@ export class Modalize extends React.C private renderChildren = (): React.ReactNode => { const { adjustToContentHeight, panGestureEnabled } = this.props; - const { adjust } = this.state; - const style = !adjustToContentHeight && adjust ? s.content__container : s.content__adjustHeight; + const style = adjustToContentHeight ? s.content__adjustHeight : s.content__container; return ( { * Use the native thread to execute the animations. * @default true */ - useNativeDriver?: boolean; + useNativeDriver: boolean; /** * Object to change the open animations @@ -306,9 +306,4 @@ export interface IState { * Store height of the keyboard. */ keyboardHeight: number; - - /** - * Store if the modal is using adjustToContentHeight props - */ - adjust: boolean | undefined; } diff --git a/src/styles.ts b/src/styles.ts index 12bc25f3..f4b0a3d8 100644 --- a/src/styles.ts +++ b/src/styles.ts @@ -99,9 +99,12 @@ export default StyleSheet.create({ content__container: { flex: 1, + flexGrow: 1, + flexShrink: 1, }, content__adjustHeight: { + flex: 0, flexGrow: 0, flexShrink: 1, },