mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
prevent sidemenu from showing when close
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
|||||||
Animated,
|
Animated,
|
||||||
TouchableWithoutFeedback,
|
TouchableWithoutFeedback,
|
||||||
Easing,
|
Easing,
|
||||||
|
DeviceEventEmitter,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
@@ -141,7 +142,6 @@ export default class SideMenu extends React.Component {
|
|||||||
|
|
||||||
changeOpacity(opacity) {
|
changeOpacity(opacity) {
|
||||||
if (opacity === 0.5) {
|
if (opacity === 0.5) {
|
||||||
console.log('i am unset');
|
|
||||||
this.overlay.setNativeProps({
|
this.overlay.setNativeProps({
|
||||||
style: {
|
style: {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@@ -156,7 +156,6 @@ export default class SideMenu extends React.Component {
|
|||||||
useNativeDriver: true,
|
useNativeDriver: true,
|
||||||
}).start(() => {
|
}).start(() => {
|
||||||
if (opacity < 0.5) {
|
if (opacity < 0.5) {
|
||||||
console.log('i am set');
|
|
||||||
this.overlay.setNativeProps({
|
this.overlay.setNativeProps({
|
||||||
style: {
|
style: {
|
||||||
display: 'none',
|
display: 'none',
|
||||||
@@ -199,6 +198,31 @@ export default class SideMenu extends React.Component {
|
|||||||
|
|
||||||
let o = newLeft / this.props.openMenuOffset;
|
let o = newLeft / this.props.openMenuOffset;
|
||||||
this.opacity.setValue(o * 0.5);
|
this.opacity.setValue(o * 0.5);
|
||||||
|
if (o > 0.015) {
|
||||||
|
this.overlayViewRef.setNativeProps({
|
||||||
|
style: {
|
||||||
|
display: 'none',
|
||||||
|
position: 'relative',
|
||||||
|
transform: [
|
||||||
|
{
|
||||||
|
translateX: -deviceScreen.width * 2,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.overlayViewRef.setNativeProps({
|
||||||
|
style: {
|
||||||
|
display: 'flex',
|
||||||
|
position: 'absolute',
|
||||||
|
transform: [
|
||||||
|
{
|
||||||
|
translateX: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.props.onMove(newLeft);
|
this.props.onMove(newLeft);
|
||||||
this.state.left.setValue(newLeft);
|
this.state.left.setValue(newLeft);
|
||||||
@@ -238,6 +262,35 @@ export default class SideMenu extends React.Component {
|
|||||||
|
|
||||||
openMenu(isOpen) {
|
openMenu(isOpen) {
|
||||||
const {hiddenMenuOffset, openMenuOffset} = this.state;
|
const {hiddenMenuOffset, openMenuOffset} = this.state;
|
||||||
|
|
||||||
|
if (isOpen) {
|
||||||
|
this.overlayViewRef.setNativeProps({
|
||||||
|
style: {
|
||||||
|
display: 'none',
|
||||||
|
position: 'relative',
|
||||||
|
transform: [
|
||||||
|
{
|
||||||
|
translateX: -deviceScreen.width * 2,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.overlayViewRef.setNativeProps({
|
||||||
|
style: {
|
||||||
|
display: 'flex',
|
||||||
|
position: 'absolute',
|
||||||
|
transform: [
|
||||||
|
{
|
||||||
|
translateX: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
|
||||||
this.changeOpacity(isOpen ? 0.5 : 0);
|
this.changeOpacity(isOpen ? 0.5 : 0);
|
||||||
this.moveLeft(isOpen ? openMenuOffset : hiddenMenuOffset);
|
this.moveLeft(isOpen ? openMenuOffset : hiddenMenuOffset);
|
||||||
|
|
||||||
@@ -255,6 +308,24 @@ export default class SideMenu extends React.Component {
|
|||||||
return this.isGestureEnabled;
|
return this.isGestureEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
DeviceEventEmitter.addListener(
|
||||||
|
'sendOverlayViewRef',
|
||||||
|
this._getOverlayViewRef,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
componentWillUnmount() {
|
||||||
|
DeviceEventEmitter.removeListener(
|
||||||
|
'sendOverlayViewRef',
|
||||||
|
this._getOverlayViewRef,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_getOverlayViewRef = data => {
|
||||||
|
this.overlayViewRef = data.ref;
|
||||||
|
console.log(this.overlayViewRef);
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const boundryStyle =
|
const boundryStyle =
|
||||||
this.props.menuPosition === 'right'
|
this.props.menuPosition === 'right'
|
||||||
|
|||||||
Reference in New Issue
Block a user