Skip to content

Commit

Permalink
feat: added param to close overlay and condition to pointerEvents #151 (
Browse files Browse the repository at this point in the history
  • Loading branch information
WesleyFaveri authored Mar 20, 2020
1 parent 6ed5593 commit 92db47b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -492,15 +492,20 @@ export class Modalize<FlatListItem = any, SectionListItem = any> extends React.C
}
};

private onHandleOverlay = ({ nativeEvent }: TapGestureHandlerStateChangeEvent): void => {
private onHandleOverlay = (
{ nativeEvent }: TapGestureHandlerStateChangeEvent,
alwaysOpen: boolean,
): void => {
const { onOverlayPress } = this.props;

if (nativeEvent.oldState === State.ACTIVE && !this.willCloseModalize) {
if (onOverlayPress) {
onOverlayPress();
}

this.close();
const dest = alwaysOpen ? 'alwaysOpen' : 'default';

this.close(dest);
}
};

Expand Down Expand Up @@ -680,7 +685,7 @@ export class Modalize<FlatListItem = any, SectionListItem = any> extends React.C
closeOnOverlayTap,
} = this.props;
const { showContent } = this.state;
const pointerEvents = alwaysOpen ? 'box-none' : 'auto';
const pointerEvents = alwaysOpen && this.modalPosition === 'initial' ? 'box-none' : 'auto';

return (
<PanGestureHandler
Expand All @@ -698,7 +703,7 @@ export class Modalize<FlatListItem = any, SectionListItem = any> extends React.C
<TapGestureHandler
ref={this.modalOverlayTap}
enabled={panGestureEnabled || closeOnOverlayTap}
onHandlerStateChange={this.onHandleOverlay}
onHandlerStateChange={resolve => this.onHandleOverlay(resolve, !!alwaysOpen)}
>
<Animated.View
style={[s.overlay__background, overlayStyle, this.overlayBackground]}
Expand Down

0 comments on commit 92db47b

Please sign in to comment.