From 3155541fa42a50bf5d2bcb72f8dc1f94a02c888f Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Wed, 15 Jan 2020 17:48:29 +0500 Subject: [PATCH] fix sidemenu overlay not hiding --- apps/mobile/src/components/SideMenu/index.js | 28 +++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/apps/mobile/src/components/SideMenu/index.js b/apps/mobile/src/components/SideMenu/index.js index 597500cc9..ea316d8c8 100644 --- a/apps/mobile/src/components/SideMenu/index.js +++ b/apps/mobile/src/components/SideMenu/index.js @@ -11,7 +11,6 @@ import { } from 'react-native'; import PropTypes from 'prop-types'; import styles from './styles'; -import * as Animatable from 'react-native-animatable'; const deviceScreen = Dimensions.get('window'); const barrierForward = deviceScreen.width / 4; @@ -120,15 +119,19 @@ export default class SideMenu extends React.Component { this.openMenu(false)}> (this.overlay = ref)} + onTouchStart={() => { + console.log('hello'); + }} style={{ display: 'none', position: 'relative', top: 0, + right: 0, left: 0, bottom: 0, - right: 0, backgroundColor: 'black', opacity: this.opacity, + zIndex: 1, }} /> @@ -138,10 +141,12 @@ export default class SideMenu extends React.Component { changeOpacity(opacity) { if (opacity === 0.5) { + console.log('i am unset'); this.overlay.setNativeProps({ style: { display: 'flex', position: 'absolute', + zIndex: 1, }, }); } @@ -150,11 +155,13 @@ export default class SideMenu extends React.Component { duration: 400, useNativeDriver: true, }).start(() => { - if (opacity === 0) { + if (opacity < 0.5) { + console.log('i am set'); this.overlay.setNativeProps({ style: { display: 'none', position: 'relative', + zIndex: -1, }, }); } @@ -176,7 +183,13 @@ export default class SideMenu extends React.Component { handlePanResponderMove(e, gestureState) { if (this.state.left.__getValue() * this.menuPositionMultiplier() >= 0) { let newLeft = this.prevLeft + gestureState.dx; - + this.overlay.setNativeProps({ + style: { + display: 'flex', + position: 'absolute', + zIndex: 1, + }, + }); if ( !this.props.bounceBackOnOverdraw && Math.abs(newLeft) > this.state.openMenuOffset @@ -210,12 +223,7 @@ export default class SideMenu extends React.Component { if (this.isOpen) { return touchMoved; } - this.overlay.setNativeProps({ - style: { - display: 'flex', - position: 'absolute', - }, - }); + const withinEdgeHitWidth = this.props.menuPosition === 'right' ? gestureState.moveX > deviceScreen.width - this.props.edgeHitWidth