Skip to content

Commit

Permalink
Cleanup after eslint upgrate
Browse files Browse the repository at this point in the history
  • Loading branch information
mxck committed Jul 25, 2018
1 parent 88f08f8 commit c0fa80f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Expand Up @@ -12,5 +12,6 @@ module.exports = {
// React
'react/require-default-props': 'off',
'react/no-typos': 'off',
'react/destructuring-assignment': 'off',
},
};
39 changes: 21 additions & 18 deletions src/Menu.js
Expand Up @@ -25,6 +25,8 @@ const MENU_PADDING_VERTICAL = 8;
const SCREEN_INDENT = 8;

class Menu extends React.Component {
_container = null;

state = {
menuState: STATES.HIDDEN,

Expand All @@ -41,8 +43,6 @@ class Menu extends React.Component {
opacityAnimation: new Animated.Value(0),
};

_container = null;

_setContainerRef = ref => {
this._container = ref;
};
Expand Down Expand Up @@ -119,7 +119,14 @@ class Menu extends React.Component {
render() {
const dimensions = Dimensions.get('screen');

const { menuSizeAnimation } = this.state;
const {
menuSizeAnimation,
menuWidth,
menuHeight,
buttonWidth,
buttonHeight,
opacityAnimation,
} = this.state;
const menuSize = {
width: menuSizeAnimation.x,
height: menuSizeAnimation.y,
Expand All @@ -130,29 +137,27 @@ class Menu extends React.Component {
const transforms = [];

// Flip by X axis if menu hits right screen border
if (left > dimensions.width - this.state.menuWidth - SCREEN_INDENT) {
if (left > dimensions.width - menuWidth - SCREEN_INDENT) {
transforms.push({
translateX: Animated.multiply(menuSizeAnimation.x, -1),
});

left += this.state.buttonWidth;
left = Math.min(dimensions.width - SCREEN_INDENT, left);
left = Math.min(dimensions.width - SCREEN_INDENT, left + buttonWidth);
}

// Flip by Y axis if menu hits bottom screen border
if (top > dimensions.height - this.state.menuHeight - SCREEN_INDENT) {
if (top > dimensions.height - menuHeight - SCREEN_INDENT) {
transforms.push({
translateY: Animated.multiply(menuSizeAnimation.y, -1),
});

top += this.state.buttonHeight;
top =
Math.min(dimensions.height - SCREEN_INDENT, top) -
Math.min(dimensions.height - SCREEN_INDENT, top + buttonHeight) -
MENU_PADDING_VERTICAL * 2;
}

const shadowMenuContainerStyle = {
opacity: this.state.opacityAnimation,
opacity: opacityAnimation,
transform: transforms,
left,
top,
Expand All @@ -162,13 +167,11 @@ class Menu extends React.Component {
const animationStarted = menuState === STATES.ANIMATING;
const modalVisible = menuState === STATES.SHOWN || animationStarted;

const { testID, button, style, children } = this.props;

return (
<View
ref={this._setContainerRef}
collapsable={false}
testID={this.props.testID}
>
<View onLayout={this._onButtonLayout}>{this.props.button}</View>
<View ref={this._setContainerRef} collapsable={false} testID={testID}>
<View onLayout={this._onButtonLayout}>{button}</View>

<Modal
visible={modalVisible}
Expand All @@ -189,13 +192,13 @@ class Menu extends React.Component {
style={[
styles.shadowMenuContainer,
shadowMenuContainerStyle,
this.props.style,
style,
]}
>
<Animated.View
style={[styles.menuContainer, animationStarted && menuSize]}
>
{this.props.children}
{children}
</Animated.View>
</Animated.View>
</View>
Expand Down

0 comments on commit c0fa80f

Please sign in to comment.