diff --git a/examples/expo/src/components/modals/FixedContent.js b/examples/expo/src/components/modals/FixedContent.js index c79730fe..eaa39fa1 100644 --- a/examples/expo/src/components/modals/FixedContent.js +++ b/examples/expo/src/components/modals/FixedContent.js @@ -39,7 +39,7 @@ export class FixedContent extends React.PureComponent { render() { return ( - + {this.renderContent()} ); diff --git a/examples/react-native-navigation/src/screens/FixedContent.js b/examples/react-native-navigation/src/screens/FixedContent.js index 6247444b..18deb5ff 100644 --- a/examples/react-native-navigation/src/screens/FixedContent.js +++ b/examples/react-native-navigation/src/screens/FixedContent.js @@ -48,7 +48,12 @@ export class FixedContent extends React.PureComponent { render() { return ( - + {this.renderContent()} ); diff --git a/examples/react-navigation/src/components/modals/FixedContent.js b/examples/react-navigation/src/components/modals/FixedContent.js index 0d79fd22..5f26aadf 100644 --- a/examples/react-navigation/src/components/modals/FixedContent.js +++ b/examples/react-navigation/src/components/modals/FixedContent.js @@ -39,7 +39,7 @@ export class FixedContent extends React.PureComponent { render() { return ( - + {this.renderContent()} ); diff --git a/src/index.tsx b/src/index.tsx index 61003cca..d818d75b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -69,7 +69,6 @@ export class Modalize extends React.C private snaps: number[] = []; private snapEnd: number; private beginScrollYValue: number = 0; - private contentAlreadyCalculated: boolean = false; private beginScrollY: Animated.Value = new Animated.Value(0); private dragY: Animated.Value = new Animated.Value(0); private translateY: Animated.Value = new Animated.Value(screenHeight); @@ -158,17 +157,13 @@ export class Modalize extends React.C } public open = (): void => { - const { adjustToContentHeight, onOpen } = this.props; + const { onOpen } = this.props; if (onOpen) { onOpen(); } - if (!adjustToContentHeight || this.contentAlreadyCalculated) { - this.onAnimateOpen(); - } else { - this.setState({ isVisible: true }); - } + this.onAnimateOpen(); }; public close = (dest: 'alwaysOpen' | 'default' = 'default'): void => { @@ -375,36 +370,6 @@ export class Modalize extends React.C }); }; - private onContentViewLayout = ({ nativeEvent }: LayoutChangeEvent): void => { - const { adjustToContentHeight, snapPoint, alwaysOpen } = this.props; - const { contentHeight, modalHeight } = this.state; - - if ( - !adjustToContentHeight || - (modalHeight || 0) <= nativeEvent.layout.height || - snapPoint || - this.contentAlreadyCalculated - ) { - if ((modalHeight || 0) <= nativeEvent.layout.height) { - this.onAnimateOpen(alwaysOpen); - } - - return; - } - - // @todo: modalHeight should be equal to the nativeEvent's height, - // and not to the state's value which is 0 at the first mount - this.setState( - { - contentHeight: nativeEvent.layout.height || contentHeight, - }, - () => { - this.contentAlreadyCalculated = true; - this.onAnimateOpen(); - }, - ); - }; - private onHandleComponent = ({ nativeEvent }: PanGestureHandlerStateChangeEvent): void => { if (nativeEvent.oldState === State.BEGAN) { this.beginScrollY.setValue(0); @@ -611,7 +576,7 @@ export class Modalize extends React.C { useNativeDriver: false }, ), scrollEventThrottle: 16, - onLayout: this.onContentViewLayout, + keyboardDismissMode, }; if (flatListProps) { @@ -623,7 +588,7 @@ export class Modalize extends React.C } return ( - + {children} );